<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.advacam.cz/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=HudecekP</id>
	<title>ADVACAM Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.advacam.cz/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=HudecekP"/>
	<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/wiki/Special:Contributions/HudecekP"/>
	<updated>2026-05-09T21:11:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1733</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1733"/>
		<updated>2026-05-06T13:01:31Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Parameter Get/Set functions (using text paramName) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200];             // metadata buffer&lt;br /&gt;
unsigned mdbs = 200;       // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warnings:&#039;&#039;&#039;&lt;br /&gt;
* Most parameters are for testing purposes only and you will &#039;&#039;&#039;not need them in normal use&#039;&#039;&#039;.&lt;br /&gt;
* Some parameters &#039;&#039;&#039;has variations between revisions&#039;&#039;&#039; of devices, firmware versions and Pixet versions.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 30;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1732</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1732"/>
		<updated>2026-05-06T12:57:21Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Metadata */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200];             // metadata buffer&lt;br /&gt;
unsigned mdbs = 200;       // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 30;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1731</id>
		<title>Pixet SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1731"/>
		<updated>2026-05-06T12:37:34Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Python API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
We provide SDK for our products. Currently it has binary and python API.&amp;lt;br&amp;gt;&lt;br /&gt;
The SDK packages are available here: https://downloads.advacam.com/sdk.php &amp;lt;br&amp;gt;&lt;br /&gt;
Each API contain 3 groups of using type:&lt;br /&gt;
&lt;br /&gt;
== Core/Basic measuring and settings ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic measuring example|Basic measuring example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cluster processing ==&lt;br /&gt;
* Searching for clusters in saved data&lt;br /&gt;
* Measuring with online searching for clusters&lt;br /&gt;
* Getting informations about clusters - Time of arrival, energy, size, ...&lt;br /&gt;
[[File:Clustering-example.png|frame|none|alt=Clustering example|Clustering example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral imaging ==&lt;br /&gt;
* Cluster processing with convert each cluster to pixel and create images by spectrum settings&lt;br /&gt;
* Getting spectrum information from whole chip, selected rectangle area or from single pixels&lt;br /&gt;
* Generating image with subpixel resolution&lt;br /&gt;
[[File:SpectralImg-example.png|frame|none|alt=Spectral Imaging examles|Spectral Imaging examles]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Binary (C/C++) APIs =&lt;br /&gt;
This APIs contains binary libraries, DLLs for Windows and SOs for Linux.&amp;lt;br&amp;gt;&lt;br /&gt;
It is intended to be &#039;&#039;&#039;easily used from C/C++&#039;&#039;&#039;, but it is also possible to use it from many other languages, e.g. &#039;&#039;&#039;C#&#039;&#039;&#039;, &#039;&#039;&#039;Visual Basic&#039;&#039;&#039;, &#039;&#039;&#039;kotlin&#039;&#039;&#039;, &#039;&#039;&#039;Xojo basic&#039;&#039;&#039;, can be used in &#039;&#039;&#039;Python via ctypes&#039;&#039;&#039;, if our Pyhon API did not suit you, ... and can be imported to the &#039;&#039;&#039;LabView&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
This API was created as simplified, for ease of use, for example in industry, so it is not object-oriented.&amp;lt;br&amp;gt;&lt;br /&gt;
Binary libraries are available in 32 and 64 bit versions for PCs and for ARMs and can be used on PC, RPi and some Android phones&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The libraries are exportes in C style:&lt;br /&gt;
* Windows DLLs - extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
* Linux SOs - extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Download the AdvacamAPIexamples package:&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API has parts:&lt;br /&gt;
&lt;br /&gt;
== Core/basic API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See [[Binary core API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clustering API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, designed for searching and processing clusters. Processing is possible online during measurement, or offline by processing data from files.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;clusteringapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Clustering API]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral Imaging API ==&lt;br /&gt;
Also with the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, which, after cluster processing, additionally creates frames, where a single pixel is created from each cluster. And energy spectrum graphs can also be easilly generated. From the entire surface or a selected section.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;spectraimgapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Spectral Imaging API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Python API =&lt;br /&gt;
The Python API was created primarily for scientific purposes, so it is quite extensive and fully object-oriented. It can be used either directly using Python installed on the computer or from a small IDE integrated in the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
API files list:&lt;br /&gt;
* &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; - Basic API file for &#039;&#039;&#039;all basic device functions&#039;&#039;&#039; like as settings, measuring and get status information.&lt;br /&gt;
* &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; - Pixel processing, used by &#039;&#039;&#039;Clustering&#039;&#039;&#039; and &#039;&#039;&#039;Spectral imaging&#039;&#039;&#039; objects.&lt;br /&gt;
* &#039;&#039;&#039;pypixetgui.pyd&#039;&#039;&#039; - API for using the Pixet GUI. Programmer can create windows, dialogs, graphs, ... (Usable only if started from the IDE integrated in the Pixet program).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This API also using the &#039;&#039;&#039;pxcore&#039;&#039;&#039; and &#039;&#039;&#039;pxproc&#039;&#039;&#039; libraries.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The &#039;&#039;&#039;pypxproc&#039;&#039;&#039; library are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See [[Python API]]&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Auxilliary files =&lt;br /&gt;
If you want using some our API, you need an auxilliary files:&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio installed|Directory of minimalistic program using binary API and working on computer with Visual Studio files installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
* The &#039;&#039;&#039;pixet.ini file&#039;&#039;&#039; located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;hwlib file(s)&#039;&#039;&#039; listed in the pixet.ini.&lt;br /&gt;
* &#039;&#039;&#039;Drivers for some devices&#039;&#039;&#039; properly installed on the computer.&lt;br /&gt;
* &#039;&#039;&#039;Additional files&#039;&#039;&#039; required for some devices. Typically FPGA firmwares. Located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;system libraries&#039;&#039;&#039; used by SDK libraries (pxcore.dll depends on: mfc110.dll, mfcloop.dll, msvcp120.dll, msvcp140.dll, msvcr110.dll, msvcr120.dll, vccorlib140.dll, vcruntime140.dll). This is not needed when the program is running from a development environment, or on a computer where the environment is installed. Don&#039;t forget to add the files when exporting for use on another computer.&lt;br /&gt;
* &#039;&#039;&#039;Device factory configuration XML file(s)&#039;&#039;&#039; for individual device. Located by pixet.ini settings, default is the &amp;quot;factory&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for saving the current configuration&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;configs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for storing log files&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;logs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
# Devices without proper configuration loaded &#039;&#039;&#039;can working, but it measuring strange things&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
# For simple test You can copy your executable file to the Pixet working directory. But it is better to create a separate directory (directories) for development, to avoid chaos in files.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1730</id>
		<title>Pixet SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1730"/>
		<updated>2026-05-06T12:35:13Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Python API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
We provide SDK for our products. Currently it has binary and python API.&amp;lt;br&amp;gt;&lt;br /&gt;
The SDK packages are available here: https://downloads.advacam.com/sdk.php &amp;lt;br&amp;gt;&lt;br /&gt;
Each API contain 3 groups of using type:&lt;br /&gt;
&lt;br /&gt;
== Core/Basic measuring and settings ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic measuring example|Basic measuring example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cluster processing ==&lt;br /&gt;
* Searching for clusters in saved data&lt;br /&gt;
* Measuring with online searching for clusters&lt;br /&gt;
* Getting informations about clusters - Time of arrival, energy, size, ...&lt;br /&gt;
[[File:Clustering-example.png|frame|none|alt=Clustering example|Clustering example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral imaging ==&lt;br /&gt;
* Cluster processing with convert each cluster to pixel and create images by spectrum settings&lt;br /&gt;
* Getting spectrum information from whole chip, selected rectangle area or from single pixels&lt;br /&gt;
* Generating image with subpixel resolution&lt;br /&gt;
[[File:SpectralImg-example.png|frame|none|alt=Spectral Imaging examles|Spectral Imaging examles]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Binary (C/C++) APIs =&lt;br /&gt;
This APIs contains binary libraries, DLLs for Windows and SOs for Linux.&amp;lt;br&amp;gt;&lt;br /&gt;
It is intended to be &#039;&#039;&#039;easily used from C/C++&#039;&#039;&#039;, but it is also possible to use it from many other languages, e.g. &#039;&#039;&#039;C#&#039;&#039;&#039;, &#039;&#039;&#039;Visual Basic&#039;&#039;&#039;, &#039;&#039;&#039;kotlin&#039;&#039;&#039;, &#039;&#039;&#039;Xojo basic&#039;&#039;&#039;, can be used in &#039;&#039;&#039;Python via ctypes&#039;&#039;&#039;, if our Pyhon API did not suit you, ... and can be imported to the &#039;&#039;&#039;LabView&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
This API was created as simplified, for ease of use, for example in industry, so it is not object-oriented.&amp;lt;br&amp;gt;&lt;br /&gt;
Binary libraries are available in 32 and 64 bit versions for PCs and for ARMs and can be used on PC, RPi and some Android phones&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The libraries are exportes in C style:&lt;br /&gt;
* Windows DLLs - extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
* Linux SOs - extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Download the AdvacamAPIexamples package:&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API has parts:&lt;br /&gt;
&lt;br /&gt;
== Core/basic API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See [[Binary core API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clustering API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, designed for searching and processing clusters. Processing is possible online during measurement, or offline by processing data from files.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;clusteringapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Clustering API]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral Imaging API ==&lt;br /&gt;
Also with the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, which, after cluster processing, additionally creates frames, where a single pixel is created from each cluster. And energy spectrum graphs can also be easilly generated. From the entire surface or a selected section.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;spectraimgapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Spectral Imaging API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Python API =&lt;br /&gt;
The Python API was created primarily for scientific purposes, so it is quite extensive and fully object-oriented. It can be used either directly using Python installed on the computer or from a small IDE integrated in the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
API files list:&lt;br /&gt;
* &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; - Basic API file for &#039;&#039;&#039;all basic device functions&#039;&#039;&#039; like as settings, measuring and get status information.&lt;br /&gt;
* &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; - Pixel processing, used by &#039;&#039;&#039;Clustering&#039;&#039;&#039; and &#039;&#039;&#039;Spectral imaging&#039;&#039;&#039; objects.&lt;br /&gt;
* &#039;&#039;&#039;pypixetgui.pyd&#039;&#039;&#039; - API for using the Pixet GUI. Programmer can create windows, dialogs, graphs, ... (Usable only if started from the IDE integrated in the Pixet program).&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The pxproc library are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This API also using the &#039;&#039;&#039;pxcore&#039;&#039;&#039; and &#039;&#039;&#039;pxproc&#039;&#039;&#039; libraries.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Python API]]&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Auxilliary files =&lt;br /&gt;
If you want using some our API, you need an auxilliary files:&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio installed|Directory of minimalistic program using binary API and working on computer with Visual Studio files installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
* The &#039;&#039;&#039;pixet.ini file&#039;&#039;&#039; located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;hwlib file(s)&#039;&#039;&#039; listed in the pixet.ini.&lt;br /&gt;
* &#039;&#039;&#039;Drivers for some devices&#039;&#039;&#039; properly installed on the computer.&lt;br /&gt;
* &#039;&#039;&#039;Additional files&#039;&#039;&#039; required for some devices. Typically FPGA firmwares. Located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;system libraries&#039;&#039;&#039; used by SDK libraries (pxcore.dll depends on: mfc110.dll, mfcloop.dll, msvcp120.dll, msvcp140.dll, msvcr110.dll, msvcr120.dll, vccorlib140.dll, vcruntime140.dll). This is not needed when the program is running from a development environment, or on a computer where the environment is installed. Don&#039;t forget to add the files when exporting for use on another computer.&lt;br /&gt;
* &#039;&#039;&#039;Device factory configuration XML file(s)&#039;&#039;&#039; for individual device. Located by pixet.ini settings, default is the &amp;quot;factory&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for saving the current configuration&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;configs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for storing log files&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;logs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
# Devices without proper configuration loaded &#039;&#039;&#039;can working, but it measuring strange things&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
# For simple test You can copy your executable file to the Pixet working directory. But it is better to create a separate directory (directories) for development, to avoid chaos in files.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1729</id>
		<title>Pixet SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Pixet_SDK&amp;diff=1729"/>
		<updated>2026-05-06T12:34:23Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Binary (C/C++) APIs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
We provide SDK for our products. Currently it has binary and python API.&amp;lt;br&amp;gt;&lt;br /&gt;
The SDK packages are available here: https://downloads.advacam.com/sdk.php &amp;lt;br&amp;gt;&lt;br /&gt;
Each API contain 3 groups of using type:&lt;br /&gt;
&lt;br /&gt;
== Core/Basic measuring and settings ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic measuring example|Basic measuring example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cluster processing ==&lt;br /&gt;
* Searching for clusters in saved data&lt;br /&gt;
* Measuring with online searching for clusters&lt;br /&gt;
* Getting informations about clusters - Time of arrival, energy, size, ...&lt;br /&gt;
[[File:Clustering-example.png|frame|none|alt=Clustering example|Clustering example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral imaging ==&lt;br /&gt;
* Cluster processing with convert each cluster to pixel and create images by spectrum settings&lt;br /&gt;
* Getting spectrum information from whole chip, selected rectangle area or from single pixels&lt;br /&gt;
* Generating image with subpixel resolution&lt;br /&gt;
[[File:SpectralImg-example.png|frame|none|alt=Spectral Imaging examles|Spectral Imaging examles]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Binary (C/C++) APIs =&lt;br /&gt;
This APIs contains binary libraries, DLLs for Windows and SOs for Linux.&amp;lt;br&amp;gt;&lt;br /&gt;
It is intended to be &#039;&#039;&#039;easily used from C/C++&#039;&#039;&#039;, but it is also possible to use it from many other languages, e.g. &#039;&#039;&#039;C#&#039;&#039;&#039;, &#039;&#039;&#039;Visual Basic&#039;&#039;&#039;, &#039;&#039;&#039;kotlin&#039;&#039;&#039;, &#039;&#039;&#039;Xojo basic&#039;&#039;&#039;, can be used in &#039;&#039;&#039;Python via ctypes&#039;&#039;&#039;, if our Pyhon API did not suit you, ... and can be imported to the &#039;&#039;&#039;LabView&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
This API was created as simplified, for ease of use, for example in industry, so it is not object-oriented.&amp;lt;br&amp;gt;&lt;br /&gt;
Binary libraries are available in 32 and 64 bit versions for PCs and for ARMs and can be used on PC, RPi and some Android phones&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The libraries are exportes in C style:&lt;br /&gt;
* Windows DLLs - extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
* Linux SOs - extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Download the AdvacamAPIexamples package:&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API has parts:&lt;br /&gt;
&lt;br /&gt;
== Core/basic API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See [[Binary core API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clustering API ==&lt;br /&gt;
With the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, designed for searching and processing clusters. Processing is possible online during measurement, or offline by processing data from files.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;clusteringapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Clustering API]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spectral Imaging API ==&lt;br /&gt;
Also with the &#039;&#039;&#039;pxproc library&#039;&#039;&#039;, which, after cluster processing, additionally creates frames, where a single pixel is created from each cluster. And energy spectrum graphs can also be easilly generated. From the entire surface or a selected section.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;spectraimgapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxproc.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxproc.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; These files are currently &#039;&#039;&#039;on demand&#039;&#039;&#039;, not included in default API package.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Binary Spectral Imaging API ]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Python API =&lt;br /&gt;
The Python API was created primarily for scientific purposes, so it is quite extensive and fully object-oriented. It can be used either directly using Python installed on the computer or from a small IDE integrated in the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
API files list:&lt;br /&gt;
* &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; - Basic API file for &#039;&#039;&#039;all basic device functions&#039;&#039;&#039; like as settings, measuring and get status information.&lt;br /&gt;
* &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; - Pixel processing, used by &#039;&#039;&#039;Clustering&#039;&#039;&#039; and &#039;&#039;&#039;Spectral imaging&#039;&#039;&#039; objects.&lt;br /&gt;
* &#039;&#039;&#039;pypixetgui.pyd&#039;&#039;&#039; - API for using the Pixet GUI. Programmer can create windows, dialogs, graphs, ... (Usable only if started from the IDE integrated in the Pixet program).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This API also using the &#039;&#039;&#039;pxcore&#039;&#039;&#039; and &#039;&#039;&#039;pxproc&#039;&#039;&#039; libraries.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Python API]]&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Auxilliary files =&lt;br /&gt;
If you want using some our API, you need an auxilliary files:&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio installed|Directory of minimalistic program using binary API and working on computer with Visual Studio files installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
* The &#039;&#039;&#039;pixet.ini file&#039;&#039;&#039; located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;hwlib file(s)&#039;&#039;&#039; listed in the pixet.ini.&lt;br /&gt;
* &#039;&#039;&#039;Drivers for some devices&#039;&#039;&#039; properly installed on the computer.&lt;br /&gt;
* &#039;&#039;&#039;Additional files&#039;&#039;&#039; required for some devices. Typically FPGA firmwares. Located in the directory with the program.&lt;br /&gt;
* &#039;&#039;&#039;system libraries&#039;&#039;&#039; used by SDK libraries (pxcore.dll depends on: mfc110.dll, mfcloop.dll, msvcp120.dll, msvcp140.dll, msvcr110.dll, msvcr120.dll, vccorlib140.dll, vcruntime140.dll). This is not needed when the program is running from a development environment, or on a computer where the environment is installed. Don&#039;t forget to add the files when exporting for use on another computer.&lt;br /&gt;
* &#039;&#039;&#039;Device factory configuration XML file(s)&#039;&#039;&#039; for individual device. Located by pixet.ini settings, default is the &amp;quot;factory&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for saving the current configuration&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;configs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
* &#039;&#039;&#039;Location for storing log files&#039;&#039;&#039;, with write enabled. Located by pixet.ini settings, default is the &amp;quot;logs&amp;quot; subdirectory of the program starting directory.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
# Devices without proper configuration loaded &#039;&#039;&#039;can working, but it measuring strange things&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
# For simple test You can copy your executable file to the Pixet working directory. But it is better to create a separate directory (directories) for development, to avoid chaos in files.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1728</id>
		<title>Files and directories of the Pixet and SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1728"/>
		<updated>2026-04-24T15:02:42Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* [Plugins] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main directory of the Pixet program =&lt;br /&gt;
[[File:Directory-pixet.png|thumb|alt=Pixet main directory if all here|Pixet main directory if all here]]&lt;br /&gt;
Here are main program files, binary libraries, API files, licence file and the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; file. Here may also be hwlibs subdirectory, special files for some devices. Their location depends on the &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
There can also be subdirectories factory, configs and logs. They are there if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is disabled in &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section.&amp;lt;br&amp;gt;&lt;br /&gt;
If here are not located configs, inis and logs, this directory can be located in Program files, or in another location where the user cannot normally write.&lt;br /&gt;
&lt;br /&gt;
; Warning&lt;br /&gt;
: It may be confusing that this directory contains device ini files, such as zest.ini, dummy.ini, ..., since installation, but if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is enabled or &#039;&#039;&#039;AppDataDir&#039;&#039;&#039;= is set, in pixet.ini, the files located here have no effect on the devices.&lt;br /&gt;
&lt;br /&gt;
= User data directory =&lt;br /&gt;
This is location of [[#The factory and the configs subdirectories|configuration]] and [[#logs|log]] files. The program must be able to write here.&amp;lt;br&amp;gt;&lt;br /&gt;
This is used, if in the &#039;&#039;&#039;[[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|pixet.ini]]&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section is located &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; (default state).&lt;br /&gt;
[[File:Directory-appdata.png|thumb|alt=AppData - user data directory|AppData - user data directory]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Default location is in the user&#039;s system application data directory, like us:&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Windows&#039;&#039;&#039; C:\Users\username\AppData\Local\PixetPro&lt;br /&gt;
* &#039;&#039;&#039;Linux&#039;&#039;&#039; ~/.config/PixetPro&lt;br /&gt;
* &#039;&#039;&#039;MacOS&#039;&#039;&#039; ~/Library/Application Support/PixetPro&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
* Location of the directory can be changed anywhere, using the &#039;&#039;&#039;AppDataDir=&#039;&#039;&#039; line in the pixet.ini.&lt;br /&gt;
* Turning on &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; does not affect the &#039;&#039;&#039;factory&#039;&#039;&#039; directory. If it is not changed using &#039;&#039;&#039;factoryDir=&#039;&#039;&#039;, it is still expected beside the running program, or in the current directory, if different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;: [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
= Subdirectories of the Pixet program =&lt;br /&gt;
&lt;br /&gt;
== The factory and the configs subdirectories ==&lt;br /&gt;
The factory directory should contain the factory default configuration XML files.&lt;br /&gt;
The Pixet core use it while starting, if the configuration file is not in the configs directory.&lt;br /&gt;
The configs directory contain configuration XML files.&lt;br /&gt;
The Pixet core try to use it while starting and save the current settings to it, if exiting.&amp;lt;br&amp;gt;&lt;br /&gt;
(This process works the same way when you start and quit the Pixet program or if you use C API functions pxcInit/pxcExit or Python API functions pypixet.start() / pixet.exitPixet()+pypixet.exit().)&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#Configuration XML files]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdirs can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== factory ===&lt;br /&gt;
It should contain the factory default configuration XML files. The Pixet core use it while starting, if the configuration file is not in the configs directory or if user click the &amp;quot;Load factory config&amp;quot; or scripts can use it by the loadFactoryConfig() method.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or can be located anywhere using the &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
Hint: If you frequently do experiments with more instances of Pixet, API-using programs or scripts and have more devices, you can use single location of the factory directory for all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Location of this directory &#039;&#039;&#039;not affected by&#039;&#039;&#039; the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini.&lt;br /&gt;
* File &#039;&#039;&#039;names must be exact&#039;&#039;&#039;, for example MiniPIX-D06-W0065.xml, AdvaPIX-C06-W0127-4.xml. It is the complete device name, where all spaces are replaced by minuses. If not exact, a load-factory like functions cannot find it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
=== configs ===&lt;br /&gt;
Contain &#039;&#039;&#039;configuration XML files for devices&#039;&#039;&#039;. The Pixet core try to use it while starting the Pixet program or in pypixet.start() method in scripts, or if the C API function pxcInit() used. And automatically save the current settings to it, while exitting the Pixet program, or if the pypixet.exit() method is used in scripts, or if the pxcExit() function used via C API.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In addition, this directory contains:&lt;br /&gt;
* &#039;&#039;&#039;Configuration XML files for filters&#039;&#039;&#039; - name format filtername_DevName ChipID.xml - for example &amp;quot;adaptiveff_MiniPIX D06-W0065.xml&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins - dev specific&#039;&#039;&#039; - name format pluginname_ChipID.ini - for example &amp;quot;devcontrol_D06-W0065.ini&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins&#039;&#039;&#039; - name format pluginname.ini - for example &amp;quot;pyscripting.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;ConfigsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== logs ==&lt;br /&gt;
[[File:Directory-logs.png|thumb|alt=The logs directory|The logs directory]]&lt;br /&gt;
Here are log files from all hardware libraries, pixet core. Files are from last Pixet core run. While next run, the core archive last log files. Subdirectories logs1, logs2, ... contains backups for last 10 sessions.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;LogsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
* Main log file is the &#039;&#039;&#039;log.log&#039;&#039;&#039;. This is the main log of the Pixet core.&lt;br /&gt;
:: You can see here the attempts to load hwlibs, whether any device was found, whether hwlib was able to start, load the configuration, ...&lt;br /&gt;
* Hwlib logs are named by each hwlib, eq. &#039;&#039;&#039;minipix.log&#039;&#039;&#039;.&lt;br /&gt;
:: You can see here the hwlib messages. It contains detected device names, serial numbers and types.&lt;br /&gt;
* Device logs are named by hwlib and each device, eq. &#039;&#039;&#039;minipixtpx3_0144 A.log&#039;&#039;&#039;.&lt;br /&gt;
:: Here are the low-level informations. It can be helpful for our Technical support if the device is naughty.&lt;br /&gt;
* The &#039;&#039;&#039;runtime.log&#039;&#039;&#039;.&lt;br /&gt;
:: Simple list of init/exit times of the Pixet core.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== hwlibs ==&lt;br /&gt;
This is the usual place for hwlib libraries, designed to work with different types of devices. The actual location of the files is defined in the &amp;lt;nowiki&amp;gt;[hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file. Default is the hwlibs subdirectory of the main program running directory. But here are a simple relative paths from the main program location and can be configured without subdirectory. It is commonly used in single-purpose programs using API.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== plugins ==&lt;br /&gt;
Default location of plugins to the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Some plugins can be need for API too.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== drivers ==&lt;br /&gt;
Installators of drivers for some devices.&lt;br /&gt;
&lt;br /&gt;
== libs ==&lt;br /&gt;
Libraries for Python scripting plugin.&lt;br /&gt;
&lt;br /&gt;
== scripts ==&lt;br /&gt;
* Sample scripts for using Python scripting plugin.&lt;br /&gt;
* The default place to search for imports used in scripts run from the Python scripting plugin. &lt;br /&gt;
&lt;br /&gt;
== Other subdirs ==&lt;br /&gt;
* samples - Sample data for demo when using virtual file device.&lt;br /&gt;
* help - PDF manuals&lt;br /&gt;
* platforms, styles - System directories of QT.&lt;br /&gt;
&lt;br /&gt;
= Main directory of the API-using programs, independent on the Pixet =&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio files installed|Directory of minimalistic program using binary API and working on computer with Visual Studio installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
User can write programs using our API. To operate them, need:&lt;br /&gt;
* &#039;&#039;&#039;Pixet core library&#039;&#039;&#039; - The core of the Pixet program. &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039;, or pxcore.so file.&lt;br /&gt;
* &#039;&#039;&#039;Pixel processing library&#039;&#039;&#039; - &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or pxproc.so library - only for Clustering and Spectral imaging use&lt;br /&gt;
* &#039;&#039;&#039;Static linking libraries&#039;&#039;&#039; - To compile binary programs on Windows, user need the pxcore.lib (and pxproc.lib). Only in compile time. Compiler must be setup for using it.&lt;br /&gt;
* &#039;&#039;&#039;Auxilliary libraries of system&#039;&#039;&#039; - If program must working on computer without an IDE installed, can need some auxilliary libs, like as: msvcp140.dll, vcruntime140.dll, etc&lt;br /&gt;
* &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; - configuration for the Pixet core. See [[#pixet.ini file]]&lt;br /&gt;
* &#039;&#039;&#039;HWlibs&#039;&#039;&#039; for the given hardware (and firmwares if devices need). See [[#hwlibs]] and [[#Device firmware files]]&lt;br /&gt;
* &#039;&#039;&#039;Device configuration files&#039;&#039;&#039; in the &#039;&#039;&#039;factory&#039;&#039;&#039; and &#039;&#039;&#039;configs&#039;&#039;&#039; directories, or elsewhere according to the settings in pixet.ini. See [[#The factory and the configs subdirectories]]&lt;br /&gt;
* &#039;&#039;&#039;Place for logs&#039;&#039;&#039; in the &#039;&#039;&#039;logs&#039;&#039;&#039; directory, or elsewhere according to the settings in pixet.ini. See [[#logs]]&lt;br /&gt;
* &#039;&#039;&#039;Python interface&#039;&#039;&#039; - To run Python scripts, &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; is needed in addition. And a &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; for Clustering and Spectral imaging objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basic files are in the API packages:&lt;br /&gt;
{{APIpackages}}&lt;br /&gt;
&lt;br /&gt;
Alternatives to run the API using programs:&lt;br /&gt;
# Copy all need files to the Project directory.&lt;br /&gt;
# While running the program, change the operating directory to the Pixet main directory.&lt;br /&gt;
# Copy the binary executable or python script to the Pixet main directory and run it from here. Useful for occasional single test, but can do problems in more extensive cases.&lt;br /&gt;
&lt;br /&gt;
= Special files =&lt;br /&gt;
&lt;br /&gt;
=== Configuration XML files ===&lt;br /&gt;
The config file contains all detector settings and you can start and continue with the settings as it was while last program exit. The factory config is config saved afther low-level detector setup, finding of bad pixels, calibrations and other factory tests.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&lt;br /&gt;
* The files must have proper names. “WidePIX-B04-W0535-10.xml” for example. If not, automatic load at start will not work. To optain proper config name, you can do the program exit and see saved filename in the configs directory.&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== pixet.ini file ==&lt;br /&gt;
This is the main configuration file of the Pixet core. It has several sections beginning with a title in square brackets. Sections contain configuration lines formated as &#039;&#039;&#039;Name=value&#039;&#039;&#039; or &#039;&#039;&#039;Name=&#039;&#039;&#039; for default value. They can also contain comments, which start with a semicolon. This way you can also deactivate some configuration lines.&amp;lt;br&amp;gt;&lt;br /&gt;
Default version of the file conaining used options and all remaining options disabled + with =default. User can edit it and enable.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Up to release 1.8.3 the [Hwlibs] section contains lines without the = symbol. This is not compliant with the INI standard. &#039;&#039;&#039;The file format will change&#039;&#039;&#039; soon. From the next version all data lines will starts with the name=.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The default &#039;&#039;&#039;path where Pixet core looks for the pixet.ini&#039;&#039;&#039; file is the same as the path to the program that started the pxcore library. So the file should be next to it. Attention, &#039;&#039;&#039;all other paths&#039;&#039;&#039; are relative to the current directory, not to the position of the program.&amp;lt;br&amp;gt;&lt;br /&gt;
So if you run c:\program&amp;amp;nbsp;files\pixet\pixet.exe from c:\users\myname, pxcore will try to load c:\program&amp;amp;nbsp;files\pixet\pixet.ini and all other relative paths (including those listed in the pixet.ini) will start with c:\users\myname.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
General settings of used directories, core and the Pixet program parameters:&lt;br /&gt;
* &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; UseAppDataDir=true - Change default location of the configs and logs subdirs and ini files to the user data directory. It also allows different login users to have different settings of same devices in same programs.&lt;br /&gt;
: Note: This does not affects the factory directory.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIniInAppDataDir&#039;&#039;&#039; PixetIniInAppDataDir=true - Enable reading the pixet.ini file from the user data directory. Very usesful if the program is located in the Program files or at other location with no write rights. It also allows different users to have different pixet.ini. Note: Enabling this option means that the Pixet core first loads this file (from the program launch point) and, after detecting this option, loads it again from the user data directory. Other settings in the default pixet.ini are therefore ignored.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIni&#039;&#039;&#039; PixetIni=C:\myPixetAppData\myPixetIni1.ini - Change name and location of the pixet.ini file. Similar to the case of PixetIniInAppDataDir, when using PixetIni=, the initialization file will be loaded again and the contents of the original file will not affect the further operation of the software.&lt;br /&gt;
* &#039;&#039;&#039;AppDataDir&#039;&#039;&#039; AppDataDir=C:\myPixetAppData\group1 - Change location of the user data directory to specified path. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings.&lt;br /&gt;
* &#039;&#039;&#039;ConfigsDir&#039;&#039;&#039; ConfigsDir=C:\myPixetAppData\configsGroup1 - Change location od the configs dir to other location. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings of devices.&lt;br /&gt;
* &#039;&#039;&#039;FactoryDir&#039;&#039;&#039; FactoryDir=C:\myPixetAppData\factory - Change location od the factory dir to other location. Useful if user have many independent places of a programs, creating new programs and testing new devices. User can simply store all factory files in one location. Or it is possible to have such a directory on the company server, where users do not have the right to write.&lt;br /&gt;
* &#039;&#039;&#039;LogsDir&#039;&#039;&#039; LogsDir=C:\temp\pxCoreDebug - Change location of the logs directory. Useful if user have many independent places of a programs, typically if creating new programs. User can simply collect all logs to one directory so that he does not have to open another one every time.&lt;br /&gt;
* &#039;&#039;&#039;Splash&#039;&#039;&#039; Splash=true - Use a splash screen when the Pixet program starting. It does not affect programs using the API.&lt;br /&gt;
* &#039;&#039;&#039;FileDevice&#039;&#039;&#039; FileDevice=true - Enable virtual &amp;quot;file device&amp;quot; independent if physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;FileDeviceWhenNoDevs&#039;&#039;&#039; = FileDeviceWhenNoDevs=false - Disable virtual &amp;quot;file device&amp;quot; if no physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;SaveSettings&#039;&#039;&#039; SaveSettings=false - Disable automatic save device settings on exit pixet core. It affects Pixet as well as programs that use the API.&lt;br /&gt;
* &#039;&#039;&#039;MaxFrameMemory&#039;&#039;&#039; MaxFrameMemory=1024 - Change the frame memory limit for multiframe acquisitions. Reserved for future use, currently not used.&lt;br /&gt;
* &#039;&#039;&#039;MainUi&#039;&#039;&#039; MainUi=devcontrol - Change main user interface plugin of the Pixet program. User can programm your own plugins and one can be used instead of the Pixet main window.&lt;br /&gt;
* &#039;&#039;&#039;LogLeaveOldLogs&#039;&#039;&#039; LogLeaveOldLogs=false - Disable archiving old log files sets.&lt;br /&gt;
* &#039;&#039;&#039;LogRotateCount&#039;&#039;&#039; LogRotateCount=15 - Change number of archived log directories.&lt;br /&gt;
* &#039;&#039;&#039;HighDPI&#039;&#039;&#039; HighDPI=true - Enable AA_EnableHighDpiScaling feature in QT GUI environment. Disable can work only in very old versions of Pixet. Currently is deprecated and allways on.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of hardware library files/paths used in startup to search and connect a devices. See the hwlibs subdirectory description for details.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039; Left is default Pixet configuration with hwlib files in the hwlibs subdirectory, right is simple arrangement with files in the program directory. Last line is disabled in both versions.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section example (dirs/flat structure)&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section (old format, before 2025/09)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
Hwlib=hwlibs\minipix.dll&lt;br /&gt;
Hwlib=hwlibs\widepix.dll&lt;br /&gt;
Hwlib=hwlibs\zem.dll&lt;br /&gt;
;Hwlib=hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
Hwlib=minipix.dll&lt;br /&gt;
Hwlib=widepix.dll&lt;br /&gt;
Hwlib=zem.dll&lt;br /&gt;
;Hwlib=zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\widepix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
;hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
minipix.dll&lt;br /&gt;
widepix.dll&lt;br /&gt;
zem.dll&lt;br /&gt;
;zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
User can disable some hwlibs using the ; symbol.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&lt;br /&gt;
* The &#039;&#039;&#039;Hwlib=&#039;&#039;&#039; must be exactly Hwlib=, it &#039;&#039;&#039;case sensitive&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of HWLIB files:&#039;&#039;&#039; Windows / Linux&lt;br /&gt;
* &#039;&#039;&#039;Minipix&#039;&#039;&#039;: minipix.dll / minipix.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with Eth&#039;&#039;&#039;: zest.dll / zest.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with USB2&#039;&#039;&#039;: widepix.dll / widepix.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix&#039;&#039;&#039; or &#039;&#039;&#039;Widepix with USB3&#039;&#039;&#039;: zem.dll (and aux. file okFrontPanel.dll - allways in the program directory) / zem.so + okFrontPanel.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix new&#039;&#039;&#039;: abrd-hwlib.dll / abrd-hwlib.so&lt;br /&gt;
* And customer-specific files for motor driving, x-ray sources, etc.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths. All files is by default in the plugins subdirectory.&lt;br /&gt;
; Note&lt;br /&gt;
: Some plugins are not only for GUI Pixet&lt;br /&gt;
: Accessing specific files like as &#039;&#039;&#039;HDF5&#039;&#039;&#039;, &#039;&#039;&#039;TIFF&#039;&#039;&#039;&lt;br /&gt;
: These plugins are also needed when using an API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&lt;br /&gt;
* The Plugin= must be exactly Plugin=, it case sensitive&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[PixelmanPlugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths with backward compatibility for old Pixelman program.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This is very obsolette. Support for Pixelman related stuff (this ini section, file formats, etc) &#039;&#039;&#039;will be removed soon&#039;&#039;&#039; without replacement.&lt;br /&gt;
&lt;br /&gt;
== Device configuration ini files ==&lt;br /&gt;
Some devices can has configuration file. Theese files are located in the program main directory or in the user data directory if the UseAppDataDir=true option used. Files have names identical to the names of the corresponding HWlibs, ending with .ini. For example, the Ethernet Widepix uses HWlib zest.dll (or zest.so on Linux) and the configuration is stored in zest.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is usually no need to edit these files, you can find details about them in the device&#039;s manual.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only for network devices it is sometimes useful to define IP addresses on which Pixet core should search for devices. Either because the general search does not work on the given network, or so that the program does not &amp;quot;steal&amp;quot; a device in another room.&lt;br /&gt;
For example, in zest.ini, each device can has its own section and an IP address defined in it:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini&amp;gt;&lt;br /&gt;
[Device0]&lt;br /&gt;
IP=10.10.1.30&lt;br /&gt;
 &lt;br /&gt;
[Device1]&lt;br /&gt;
IP=10.10.1.31&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Device firmware files ==&lt;br /&gt;
Some devices need firmware files to upload while initialization process. These files are allways located in the program directory. Names are typically composed from HWlib name and readout chip name (zemtpx3.rbf for example).&amp;lt;br&amp;gt;&lt;br /&gt;
List of this kind of files:&amp;lt;br&amp;gt;&lt;br /&gt;
zestwpx.bit, zemwpxf.rbf, zemtpx3.rbf, zemtpx3quad.rbf, zemtpx.rbf, cyptpx3pix.rbf&amp;lt;br&amp;gt;&lt;br /&gt;
Note: The standard Pixet distribution that comes with your device only contains the files for that device, so you usually won&#039;t see all of these files. And Minipix, for example, doesn&#039;t need any of it.&lt;br /&gt;
&lt;br /&gt;
== Insidious complications with files/dirs ==&lt;br /&gt;
Let&#039;s have the following program and with it pypixet.pyd and other necessary files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir(&amp;quot;test-output&amp;quot;)&lt;br /&gt;
import pypixet&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pixet core init...&amp;quot;)&lt;br /&gt;
pypixet.start()&lt;br /&gt;
pixet=pypixet.pixet&lt;br /&gt;
devices = pixet.devices()&lt;br /&gt;
dev = devices[0]&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition (3 frames @ 1 sec) - start&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(3, 1, pixet.PX_FTYPE_AUTODETECT, &amp;quot;example.png&amp;quot;)&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition - end:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
pixet.exitPixet()&lt;br /&gt;
pypixet.exit()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This program normally works with e.g. Minipix, but does not work with e.q. Advapix. Crashes at pypixet.start() or has not any detected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The problem is that hwlibs load their files eg firmware from the current directory. Minipix not need any other files, Advapix need a firmware .rbf file. Moving &#039;&#039;&#039;os.chdir&#039;&#039;&#039; after &#039;&#039;&#039;pypixet.start()&#039;&#039;&#039; solves the problem.&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1727</id>
		<title>Files and directories of the Pixet and SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1727"/>
		<updated>2026-04-24T14:08:51Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* [Hwlibs] */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main directory of the Pixet program =&lt;br /&gt;
[[File:Directory-pixet.png|thumb|alt=Pixet main directory if all here|Pixet main directory if all here]]&lt;br /&gt;
Here are main program files, binary libraries, API files, licence file and the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; file. Here may also be hwlibs subdirectory, special files for some devices. Their location depends on the &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
There can also be subdirectories factory, configs and logs. They are there if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is disabled in &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section.&amp;lt;br&amp;gt;&lt;br /&gt;
If here are not located configs, inis and logs, this directory can be located in Program files, or in another location where the user cannot normally write.&lt;br /&gt;
&lt;br /&gt;
; Warning&lt;br /&gt;
: It may be confusing that this directory contains device ini files, such as zest.ini, dummy.ini, ..., since installation, but if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is enabled or &#039;&#039;&#039;AppDataDir&#039;&#039;&#039;= is set, in pixet.ini, the files located here have no effect on the devices.&lt;br /&gt;
&lt;br /&gt;
= User data directory =&lt;br /&gt;
This is location of [[#The factory and the configs subdirectories|configuration]] and [[#logs|log]] files. The program must be able to write here.&amp;lt;br&amp;gt;&lt;br /&gt;
This is used, if in the &#039;&#039;&#039;[[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|pixet.ini]]&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section is located &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; (default state).&lt;br /&gt;
[[File:Directory-appdata.png|thumb|alt=AppData - user data directory|AppData - user data directory]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Default location is in the user&#039;s system application data directory, like us:&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Windows&#039;&#039;&#039; C:\Users\username\AppData\Local\PixetPro&lt;br /&gt;
* &#039;&#039;&#039;Linux&#039;&#039;&#039; ~/.config/PixetPro&lt;br /&gt;
* &#039;&#039;&#039;MacOS&#039;&#039;&#039; ~/Library/Application Support/PixetPro&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
* Location of the directory can be changed anywhere, using the &#039;&#039;&#039;AppDataDir=&#039;&#039;&#039; line in the pixet.ini.&lt;br /&gt;
* Turning on &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; does not affect the &#039;&#039;&#039;factory&#039;&#039;&#039; directory. If it is not changed using &#039;&#039;&#039;factoryDir=&#039;&#039;&#039;, it is still expected beside the running program, or in the current directory, if different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;: [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
= Subdirectories of the Pixet program =&lt;br /&gt;
&lt;br /&gt;
== The factory and the configs subdirectories ==&lt;br /&gt;
The factory directory should contain the factory default configuration XML files.&lt;br /&gt;
The Pixet core use it while starting, if the configuration file is not in the configs directory.&lt;br /&gt;
The configs directory contain configuration XML files.&lt;br /&gt;
The Pixet core try to use it while starting and save the current settings to it, if exiting.&amp;lt;br&amp;gt;&lt;br /&gt;
(This process works the same way when you start and quit the Pixet program or if you use C API functions pxcInit/pxcExit or Python API functions pypixet.start() / pixet.exitPixet()+pypixet.exit().)&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#Configuration XML files]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdirs can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== factory ===&lt;br /&gt;
It should contain the factory default configuration XML files. The Pixet core use it while starting, if the configuration file is not in the configs directory or if user click the &amp;quot;Load factory config&amp;quot; or scripts can use it by the loadFactoryConfig() method.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or can be located anywhere using the &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
Hint: If you frequently do experiments with more instances of Pixet, API-using programs or scripts and have more devices, you can use single location of the factory directory for all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Location of this directory &#039;&#039;&#039;not affected by&#039;&#039;&#039; the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini.&lt;br /&gt;
* File &#039;&#039;&#039;names must be exact&#039;&#039;&#039;, for example MiniPIX-D06-W0065.xml, AdvaPIX-C06-W0127-4.xml. It is the complete device name, where all spaces are replaced by minuses. If not exact, a load-factory like functions cannot find it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
=== configs ===&lt;br /&gt;
Contain &#039;&#039;&#039;configuration XML files for devices&#039;&#039;&#039;. The Pixet core try to use it while starting the Pixet program or in pypixet.start() method in scripts, or if the C API function pxcInit() used. And automatically save the current settings to it, while exitting the Pixet program, or if the pypixet.exit() method is used in scripts, or if the pxcExit() function used via C API.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In addition, this directory contains:&lt;br /&gt;
* &#039;&#039;&#039;Configuration XML files for filters&#039;&#039;&#039; - name format filtername_DevName ChipID.xml - for example &amp;quot;adaptiveff_MiniPIX D06-W0065.xml&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins - dev specific&#039;&#039;&#039; - name format pluginname_ChipID.ini - for example &amp;quot;devcontrol_D06-W0065.ini&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins&#039;&#039;&#039; - name format pluginname.ini - for example &amp;quot;pyscripting.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;ConfigsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== logs ==&lt;br /&gt;
[[File:Directory-logs.png|thumb|alt=The logs directory|The logs directory]]&lt;br /&gt;
Here are log files from all hardware libraries, pixet core. Files are from last Pixet core run. While next run, the core archive last log files. Subdirectories logs1, logs2, ... contains backups for last 10 sessions.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;LogsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
* Main log file is the &#039;&#039;&#039;log.log&#039;&#039;&#039;. This is the main log of the Pixet core.&lt;br /&gt;
:: You can see here the attempts to load hwlibs, whether any device was found, whether hwlib was able to start, load the configuration, ...&lt;br /&gt;
* Hwlib logs are named by each hwlib, eq. &#039;&#039;&#039;minipix.log&#039;&#039;&#039;.&lt;br /&gt;
:: You can see here the hwlib messages. It contains detected device names, serial numbers and types.&lt;br /&gt;
* Device logs are named by hwlib and each device, eq. &#039;&#039;&#039;minipixtpx3_0144 A.log&#039;&#039;&#039;.&lt;br /&gt;
:: Here are the low-level informations. It can be helpful for our Technical support if the device is naughty.&lt;br /&gt;
* The &#039;&#039;&#039;runtime.log&#039;&#039;&#039;.&lt;br /&gt;
:: Simple list of init/exit times of the Pixet core.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== hwlibs ==&lt;br /&gt;
This is the usual place for hwlib libraries, designed to work with different types of devices. The actual location of the files is defined in the &amp;lt;nowiki&amp;gt;[hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file. Default is the hwlibs subdirectory of the main program running directory. But here are a simple relative paths from the main program location and can be configured without subdirectory. It is commonly used in single-purpose programs using API.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== plugins ==&lt;br /&gt;
Default location of plugins to the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Some plugins can be need for API too.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== drivers ==&lt;br /&gt;
Installators of drivers for some devices.&lt;br /&gt;
&lt;br /&gt;
== libs ==&lt;br /&gt;
Libraries for Python scripting plugin.&lt;br /&gt;
&lt;br /&gt;
== scripts ==&lt;br /&gt;
* Sample scripts for using Python scripting plugin.&lt;br /&gt;
* The default place to search for imports used in scripts run from the Python scripting plugin. &lt;br /&gt;
&lt;br /&gt;
== Other subdirs ==&lt;br /&gt;
* samples - Sample data for demo when using virtual file device.&lt;br /&gt;
* help - PDF manuals&lt;br /&gt;
* platforms, styles - System directories of QT.&lt;br /&gt;
&lt;br /&gt;
= Main directory of the API-using programs, independent on the Pixet =&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio files installed|Directory of minimalistic program using binary API and working on computer with Visual Studio installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
User can write programs using our API. To operate them, need:&lt;br /&gt;
* &#039;&#039;&#039;Pixet core library&#039;&#039;&#039; - The core of the Pixet program. &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039;, or pxcore.so file.&lt;br /&gt;
* &#039;&#039;&#039;Pixel processing library&#039;&#039;&#039; - &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or pxproc.so library - only for Clustering and Spectral imaging use&lt;br /&gt;
* &#039;&#039;&#039;Static linking libraries&#039;&#039;&#039; - To compile binary programs on Windows, user need the pxcore.lib (and pxproc.lib). Only in compile time. Compiler must be setup for using it.&lt;br /&gt;
* &#039;&#039;&#039;Auxilliary libraries of system&#039;&#039;&#039; - If program must working on computer without an IDE installed, can need some auxilliary libs, like as: msvcp140.dll, vcruntime140.dll, etc&lt;br /&gt;
* &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; - configuration for the Pixet core. See [[#pixet.ini file]]&lt;br /&gt;
* &#039;&#039;&#039;HWlibs&#039;&#039;&#039; for the given hardware (and firmwares if devices need). See [[#hwlibs]] and [[#Device firmware files]]&lt;br /&gt;
* &#039;&#039;&#039;Device configuration files&#039;&#039;&#039; in the &#039;&#039;&#039;factory&#039;&#039;&#039; and &#039;&#039;&#039;configs&#039;&#039;&#039; directories, or elsewhere according to the settings in pixet.ini. See [[#The factory and the configs subdirectories]]&lt;br /&gt;
* &#039;&#039;&#039;Place for logs&#039;&#039;&#039; in the &#039;&#039;&#039;logs&#039;&#039;&#039; directory, or elsewhere according to the settings in pixet.ini. See [[#logs]]&lt;br /&gt;
* &#039;&#039;&#039;Python interface&#039;&#039;&#039; - To run Python scripts, &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; is needed in addition. And a &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; for Clustering and Spectral imaging objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basic files are in the API packages:&lt;br /&gt;
{{APIpackages}}&lt;br /&gt;
&lt;br /&gt;
Alternatives to run the API using programs:&lt;br /&gt;
# Copy all need files to the Project directory.&lt;br /&gt;
# While running the program, change the operating directory to the Pixet main directory.&lt;br /&gt;
# Copy the binary executable or python script to the Pixet main directory and run it from here. Useful for occasional single test, but can do problems in more extensive cases.&lt;br /&gt;
&lt;br /&gt;
= Special files =&lt;br /&gt;
&lt;br /&gt;
=== Configuration XML files ===&lt;br /&gt;
The config file contains all detector settings and you can start and continue with the settings as it was while last program exit. The factory config is config saved afther low-level detector setup, finding of bad pixels, calibrations and other factory tests.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&lt;br /&gt;
* The files must have proper names. “WidePIX-B04-W0535-10.xml” for example. If not, automatic load at start will not work. To optain proper config name, you can do the program exit and see saved filename in the configs directory.&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== pixet.ini file ==&lt;br /&gt;
This is the main configuration file of the Pixet core. It has several sections beginning with a title in square brackets. Sections contain configuration lines formated as &#039;&#039;&#039;Name=value&#039;&#039;&#039; or &#039;&#039;&#039;Name=&#039;&#039;&#039; for default value. They can also contain comments, which start with a semicolon. This way you can also deactivate some configuration lines.&amp;lt;br&amp;gt;&lt;br /&gt;
Default version of the file conaining used options and all remaining options disabled + with =default. User can edit it and enable.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Up to release 1.8.3 the [Hwlibs] section contains lines without the = symbol. This is not compliant with the INI standard. &#039;&#039;&#039;The file format will change&#039;&#039;&#039; soon. From the next version all data lines will starts with the name=.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The default &#039;&#039;&#039;path where Pixet core looks for the pixet.ini&#039;&#039;&#039; file is the same as the path to the program that started the pxcore library. So the file should be next to it. Attention, &#039;&#039;&#039;all other paths&#039;&#039;&#039; are relative to the current directory, not to the position of the program.&amp;lt;br&amp;gt;&lt;br /&gt;
So if you run c:\program&amp;amp;nbsp;files\pixet\pixet.exe from c:\users\myname, pxcore will try to load c:\program&amp;amp;nbsp;files\pixet\pixet.ini and all other relative paths (including those listed in the pixet.ini) will start with c:\users\myname.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
General settings of used directories, core and the Pixet program parameters:&lt;br /&gt;
* &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; UseAppDataDir=true - Change default location of the configs and logs subdirs and ini files to the user data directory. It also allows different login users to have different settings of same devices in same programs.&lt;br /&gt;
: Note: This does not affects the factory directory.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIniInAppDataDir&#039;&#039;&#039; PixetIniInAppDataDir=true - Enable reading the pixet.ini file from the user data directory. Very usesful if the program is located in the Program files or at other location with no write rights. It also allows different users to have different pixet.ini. Note: Enabling this option means that the Pixet core first loads this file (from the program launch point) and, after detecting this option, loads it again from the user data directory. Other settings in the default pixet.ini are therefore ignored.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIni&#039;&#039;&#039; PixetIni=C:\myPixetAppData\myPixetIni1.ini - Change name and location of the pixet.ini file. Similar to the case of PixetIniInAppDataDir, when using PixetIni=, the initialization file will be loaded again and the contents of the original file will not affect the further operation of the software.&lt;br /&gt;
* &#039;&#039;&#039;AppDataDir&#039;&#039;&#039; AppDataDir=C:\myPixetAppData\group1 - Change location of the user data directory to specified path. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings.&lt;br /&gt;
* &#039;&#039;&#039;ConfigsDir&#039;&#039;&#039; ConfigsDir=C:\myPixetAppData\configsGroup1 - Change location od the configs dir to other location. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings of devices.&lt;br /&gt;
* &#039;&#039;&#039;FactoryDir&#039;&#039;&#039; FactoryDir=C:\myPixetAppData\factory - Change location od the factory dir to other location. Useful if user have many independent places of a programs, creating new programs and testing new devices. User can simply store all factory files in one location. Or it is possible to have such a directory on the company server, where users do not have the right to write.&lt;br /&gt;
* &#039;&#039;&#039;LogsDir&#039;&#039;&#039; LogsDir=C:\temp\pxCoreDebug - Change location of the logs directory. Useful if user have many independent places of a programs, typically if creating new programs. User can simply collect all logs to one directory so that he does not have to open another one every time.&lt;br /&gt;
* &#039;&#039;&#039;Splash&#039;&#039;&#039; Splash=true - Use a splash screen when the Pixet program starting. It does not affect programs using the API.&lt;br /&gt;
* &#039;&#039;&#039;FileDevice&#039;&#039;&#039; FileDevice=true - Enable virtual &amp;quot;file device&amp;quot; independent if physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;FileDeviceWhenNoDevs&#039;&#039;&#039; = FileDeviceWhenNoDevs=false - Disable virtual &amp;quot;file device&amp;quot; if no physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;SaveSettings&#039;&#039;&#039; SaveSettings=false - Disable automatic save device settings on exit pixet core. It affects Pixet as well as programs that use the API.&lt;br /&gt;
* &#039;&#039;&#039;MaxFrameMemory&#039;&#039;&#039; MaxFrameMemory=1024 - Change the frame memory limit for multiframe acquisitions. Reserved for future use, currently not used.&lt;br /&gt;
* &#039;&#039;&#039;MainUi&#039;&#039;&#039; MainUi=devcontrol - Change main user interface plugin of the Pixet program. User can programm your own plugins and one can be used instead of the Pixet main window.&lt;br /&gt;
* &#039;&#039;&#039;LogLeaveOldLogs&#039;&#039;&#039; LogLeaveOldLogs=false - Disable archiving old log files sets.&lt;br /&gt;
* &#039;&#039;&#039;LogRotateCount&#039;&#039;&#039; LogRotateCount=15 - Change number of archived log directories.&lt;br /&gt;
* &#039;&#039;&#039;HighDPI&#039;&#039;&#039; HighDPI=true - Enable AA_EnableHighDpiScaling feature in QT GUI environment. Disable can work only in very old versions of Pixet. Currently is deprecated and allways on.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of hardware library files/paths used in startup to search and connect a devices. See the hwlibs subdirectory description for details.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039; Left is default Pixet configuration with hwlib files in the hwlibs subdirectory, right is simple arrangement with files in the program directory. Last line is disabled in both versions.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section example (dirs/flat structure)&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section (old format, before 2025/09)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
Hwlib=hwlibs\minipix.dll&lt;br /&gt;
Hwlib=hwlibs\widepix.dll&lt;br /&gt;
Hwlib=hwlibs\zem.dll&lt;br /&gt;
;Hwlib=hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
Hwlib=minipix.dll&lt;br /&gt;
Hwlib=widepix.dll&lt;br /&gt;
Hwlib=zem.dll&lt;br /&gt;
;Hwlib=zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\widepix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
;hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
minipix.dll&lt;br /&gt;
widepix.dll&lt;br /&gt;
zem.dll&lt;br /&gt;
;zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
User can disable some hwlibs using the ; symbol.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&lt;br /&gt;
* The &#039;&#039;&#039;Hwlib=&#039;&#039;&#039; must be exactly Hwlib=, it &#039;&#039;&#039;case sensitive&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of HWLIB files:&#039;&#039;&#039; Windows / Linux&lt;br /&gt;
* &#039;&#039;&#039;Minipix&#039;&#039;&#039;: minipix.dll / minipix.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with Eth&#039;&#039;&#039;: zest.dll / zest.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with USB2&#039;&#039;&#039;: widepix.dll / widepix.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix&#039;&#039;&#039; or &#039;&#039;&#039;Widepix with USB3&#039;&#039;&#039;: zem.dll (and aux. file okFrontPanel.dll - allways in the program directory) / zem.so + okFrontPanel.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix new&#039;&#039;&#039;: abrd-hwlib.dll / abrd-hwlib.so&lt;br /&gt;
* And customer-specific files for motor driving, x-ray sources, etc.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths. All files is by default in the plugins subdirectory.&lt;br /&gt;
; Note&lt;br /&gt;
: Some plugins are not only for GUI Pixet&lt;br /&gt;
: Accessing specific files like as &#039;&#039;&#039;HDF5&#039;&#039;&#039;, &#039;&#039;&#039;TIFF&#039;&#039;&#039;&lt;br /&gt;
: These plugins are also needed when using an API.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[PixelmanPlugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths with backward compatibility for old Pixelman program.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This is very obsolette. Support for Pixelman related stuff (this ini section, file formats, etc) &#039;&#039;&#039;will be removed soon&#039;&#039;&#039; without replacement.&lt;br /&gt;
&lt;br /&gt;
== Device configuration ini files ==&lt;br /&gt;
Some devices can has configuration file. Theese files are located in the program main directory or in the user data directory if the UseAppDataDir=true option used. Files have names identical to the names of the corresponding HWlibs, ending with .ini. For example, the Ethernet Widepix uses HWlib zest.dll (or zest.so on Linux) and the configuration is stored in zest.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is usually no need to edit these files, you can find details about them in the device&#039;s manual.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only for network devices it is sometimes useful to define IP addresses on which Pixet core should search for devices. Either because the general search does not work on the given network, or so that the program does not &amp;quot;steal&amp;quot; a device in another room.&lt;br /&gt;
For example, in zest.ini, each device can has its own section and an IP address defined in it:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini&amp;gt;&lt;br /&gt;
[Device0]&lt;br /&gt;
IP=10.10.1.30&lt;br /&gt;
 &lt;br /&gt;
[Device1]&lt;br /&gt;
IP=10.10.1.31&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Device firmware files ==&lt;br /&gt;
Some devices need firmware files to upload while initialization process. These files are allways located in the program directory. Names are typically composed from HWlib name and readout chip name (zemtpx3.rbf for example).&amp;lt;br&amp;gt;&lt;br /&gt;
List of this kind of files:&amp;lt;br&amp;gt;&lt;br /&gt;
zestwpx.bit, zemwpxf.rbf, zemtpx3.rbf, zemtpx3quad.rbf, zemtpx.rbf, cyptpx3pix.rbf&amp;lt;br&amp;gt;&lt;br /&gt;
Note: The standard Pixet distribution that comes with your device only contains the files for that device, so you usually won&#039;t see all of these files. And Minipix, for example, doesn&#039;t need any of it.&lt;br /&gt;
&lt;br /&gt;
== Insidious complications with files/dirs ==&lt;br /&gt;
Let&#039;s have the following program and with it pypixet.pyd and other necessary files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir(&amp;quot;test-output&amp;quot;)&lt;br /&gt;
import pypixet&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pixet core init...&amp;quot;)&lt;br /&gt;
pypixet.start()&lt;br /&gt;
pixet=pypixet.pixet&lt;br /&gt;
devices = pixet.devices()&lt;br /&gt;
dev = devices[0]&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition (3 frames @ 1 sec) - start&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(3, 1, pixet.PX_FTYPE_AUTODETECT, &amp;quot;example.png&amp;quot;)&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition - end:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
pixet.exitPixet()&lt;br /&gt;
pypixet.exit()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This program normally works with e.g. Minipix, but does not work with e.q. Advapix. Crashes at pypixet.start() or has not any detected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The problem is that hwlibs load their files eg firmware from the current directory. Minipix not need any other files, Advapix need a firmware .rbf file. Moving &#039;&#039;&#039;os.chdir&#039;&#039;&#039; after &#039;&#039;&#039;pypixet.start()&#039;&#039;&#039; solves the problem.&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1726</id>
		<title>Files and directories of the Pixet and SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1726"/>
		<updated>2026-04-24T14:01:34Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Subdirectories of the Pixet program */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main directory of the Pixet program =&lt;br /&gt;
[[File:Directory-pixet.png|thumb|alt=Pixet main directory if all here|Pixet main directory if all here]]&lt;br /&gt;
Here are main program files, binary libraries, API files, licence file and the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; file. Here may also be hwlibs subdirectory, special files for some devices. Their location depends on the &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
There can also be subdirectories factory, configs and logs. They are there if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is disabled in &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section.&amp;lt;br&amp;gt;&lt;br /&gt;
If here are not located configs, inis and logs, this directory can be located in Program files, or in another location where the user cannot normally write.&lt;br /&gt;
&lt;br /&gt;
; Warning&lt;br /&gt;
: It may be confusing that this directory contains device ini files, such as zest.ini, dummy.ini, ..., since installation, but if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is enabled or &#039;&#039;&#039;AppDataDir&#039;&#039;&#039;= is set, in pixet.ini, the files located here have no effect on the devices.&lt;br /&gt;
&lt;br /&gt;
= User data directory =&lt;br /&gt;
This is location of [[#The factory and the configs subdirectories|configuration]] and [[#logs|log]] files. The program must be able to write here.&amp;lt;br&amp;gt;&lt;br /&gt;
This is used, if in the &#039;&#039;&#039;[[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|pixet.ini]]&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section is located &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; (default state).&lt;br /&gt;
[[File:Directory-appdata.png|thumb|alt=AppData - user data directory|AppData - user data directory]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Default location is in the user&#039;s system application data directory, like us:&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Windows&#039;&#039;&#039; C:\Users\username\AppData\Local\PixetPro&lt;br /&gt;
* &#039;&#039;&#039;Linux&#039;&#039;&#039; ~/.config/PixetPro&lt;br /&gt;
* &#039;&#039;&#039;MacOS&#039;&#039;&#039; ~/Library/Application Support/PixetPro&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
* Location of the directory can be changed anywhere, using the &#039;&#039;&#039;AppDataDir=&#039;&#039;&#039; line in the pixet.ini.&lt;br /&gt;
* Turning on &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; does not affect the &#039;&#039;&#039;factory&#039;&#039;&#039; directory. If it is not changed using &#039;&#039;&#039;factoryDir=&#039;&#039;&#039;, it is still expected beside the running program, or in the current directory, if different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;: [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
= Subdirectories of the Pixet program =&lt;br /&gt;
&lt;br /&gt;
== The factory and the configs subdirectories ==&lt;br /&gt;
The factory directory should contain the factory default configuration XML files.&lt;br /&gt;
The Pixet core use it while starting, if the configuration file is not in the configs directory.&lt;br /&gt;
The configs directory contain configuration XML files.&lt;br /&gt;
The Pixet core try to use it while starting and save the current settings to it, if exiting.&amp;lt;br&amp;gt;&lt;br /&gt;
(This process works the same way when you start and quit the Pixet program or if you use C API functions pxcInit/pxcExit or Python API functions pypixet.start() / pixet.exitPixet()+pypixet.exit().)&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#Configuration XML files]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdirs can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== factory ===&lt;br /&gt;
It should contain the factory default configuration XML files. The Pixet core use it while starting, if the configuration file is not in the configs directory or if user click the &amp;quot;Load factory config&amp;quot; or scripts can use it by the loadFactoryConfig() method.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or can be located anywhere using the &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
Hint: If you frequently do experiments with more instances of Pixet, API-using programs or scripts and have more devices, you can use single location of the factory directory for all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Location of this directory &#039;&#039;&#039;not affected by&#039;&#039;&#039; the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini.&lt;br /&gt;
* File &#039;&#039;&#039;names must be exact&#039;&#039;&#039;, for example MiniPIX-D06-W0065.xml, AdvaPIX-C06-W0127-4.xml. It is the complete device name, where all spaces are replaced by minuses. If not exact, a load-factory like functions cannot find it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
=== configs ===&lt;br /&gt;
Contain &#039;&#039;&#039;configuration XML files for devices&#039;&#039;&#039;. The Pixet core try to use it while starting the Pixet program or in pypixet.start() method in scripts, or if the C API function pxcInit() used. And automatically save the current settings to it, while exitting the Pixet program, or if the pypixet.exit() method is used in scripts, or if the pxcExit() function used via C API.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In addition, this directory contains:&lt;br /&gt;
* &#039;&#039;&#039;Configuration XML files for filters&#039;&#039;&#039; - name format filtername_DevName ChipID.xml - for example &amp;quot;adaptiveff_MiniPIX D06-W0065.xml&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins - dev specific&#039;&#039;&#039; - name format pluginname_ChipID.ini - for example &amp;quot;devcontrol_D06-W0065.ini&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins&#039;&#039;&#039; - name format pluginname.ini - for example &amp;quot;pyscripting.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;ConfigsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== logs ==&lt;br /&gt;
[[File:Directory-logs.png|thumb|alt=The logs directory|The logs directory]]&lt;br /&gt;
Here are log files from all hardware libraries, pixet core. Files are from last Pixet core run. While next run, the core archive last log files. Subdirectories logs1, logs2, ... contains backups for last 10 sessions.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;LogsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
* Main log file is the &#039;&#039;&#039;log.log&#039;&#039;&#039;. This is the main log of the Pixet core.&lt;br /&gt;
:: You can see here the attempts to load hwlibs, whether any device was found, whether hwlib was able to start, load the configuration, ...&lt;br /&gt;
* Hwlib logs are named by each hwlib, eq. &#039;&#039;&#039;minipix.log&#039;&#039;&#039;.&lt;br /&gt;
:: You can see here the hwlib messages. It contains detected device names, serial numbers and types.&lt;br /&gt;
* Device logs are named by hwlib and each device, eq. &#039;&#039;&#039;minipixtpx3_0144 A.log&#039;&#039;&#039;.&lt;br /&gt;
:: Here are the low-level informations. It can be helpful for our Technical support if the device is naughty.&lt;br /&gt;
* The &#039;&#039;&#039;runtime.log&#039;&#039;&#039;.&lt;br /&gt;
:: Simple list of init/exit times of the Pixet core.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== hwlibs ==&lt;br /&gt;
This is the usual place for hwlib libraries, designed to work with different types of devices. The actual location of the files is defined in the &amp;lt;nowiki&amp;gt;[hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file. Default is the hwlibs subdirectory of the main program running directory. But here are a simple relative paths from the main program location and can be configured without subdirectory. It is commonly used in single-purpose programs using API.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== plugins ==&lt;br /&gt;
Default location of plugins to the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Some plugins can be need for API too.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]] - &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
== drivers ==&lt;br /&gt;
Installators of drivers for some devices.&lt;br /&gt;
&lt;br /&gt;
== libs ==&lt;br /&gt;
Libraries for Python scripting plugin.&lt;br /&gt;
&lt;br /&gt;
== scripts ==&lt;br /&gt;
* Sample scripts for using Python scripting plugin.&lt;br /&gt;
* The default place to search for imports used in scripts run from the Python scripting plugin. &lt;br /&gt;
&lt;br /&gt;
== Other subdirs ==&lt;br /&gt;
* samples - Sample data for demo when using virtual file device.&lt;br /&gt;
* help - PDF manuals&lt;br /&gt;
* platforms, styles - System directories of QT.&lt;br /&gt;
&lt;br /&gt;
= Main directory of the API-using programs, independent on the Pixet =&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio files installed|Directory of minimalistic program using binary API and working on computer with Visual Studio installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
User can write programs using our API. To operate them, need:&lt;br /&gt;
* &#039;&#039;&#039;Pixet core library&#039;&#039;&#039; - The core of the Pixet program. &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039;, or pxcore.so file.&lt;br /&gt;
* &#039;&#039;&#039;Pixel processing library&#039;&#039;&#039; - &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or pxproc.so library - only for Clustering and Spectral imaging use&lt;br /&gt;
* &#039;&#039;&#039;Static linking libraries&#039;&#039;&#039; - To compile binary programs on Windows, user need the pxcore.lib (and pxproc.lib). Only in compile time. Compiler must be setup for using it.&lt;br /&gt;
* &#039;&#039;&#039;Auxilliary libraries of system&#039;&#039;&#039; - If program must working on computer without an IDE installed, can need some auxilliary libs, like as: msvcp140.dll, vcruntime140.dll, etc&lt;br /&gt;
* &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; - configuration for the Pixet core. See [[#pixet.ini file]]&lt;br /&gt;
* &#039;&#039;&#039;HWlibs&#039;&#039;&#039; for the given hardware (and firmwares if devices need). See [[#hwlibs]] and [[#Device firmware files]]&lt;br /&gt;
* &#039;&#039;&#039;Device configuration files&#039;&#039;&#039; in the &#039;&#039;&#039;factory&#039;&#039;&#039; and &#039;&#039;&#039;configs&#039;&#039;&#039; directories, or elsewhere according to the settings in pixet.ini. See [[#The factory and the configs subdirectories]]&lt;br /&gt;
* &#039;&#039;&#039;Place for logs&#039;&#039;&#039; in the &#039;&#039;&#039;logs&#039;&#039;&#039; directory, or elsewhere according to the settings in pixet.ini. See [[#logs]]&lt;br /&gt;
* &#039;&#039;&#039;Python interface&#039;&#039;&#039; - To run Python scripts, &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; is needed in addition. And a &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; for Clustering and Spectral imaging objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basic files are in the API packages:&lt;br /&gt;
{{APIpackages}}&lt;br /&gt;
&lt;br /&gt;
Alternatives to run the API using programs:&lt;br /&gt;
# Copy all need files to the Project directory.&lt;br /&gt;
# While running the program, change the operating directory to the Pixet main directory.&lt;br /&gt;
# Copy the binary executable or python script to the Pixet main directory and run it from here. Useful for occasional single test, but can do problems in more extensive cases.&lt;br /&gt;
&lt;br /&gt;
= Special files =&lt;br /&gt;
&lt;br /&gt;
=== Configuration XML files ===&lt;br /&gt;
The config file contains all detector settings and you can start and continue with the settings as it was while last program exit. The factory config is config saved afther low-level detector setup, finding of bad pixels, calibrations and other factory tests.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&lt;br /&gt;
* The files must have proper names. “WidePIX-B04-W0535-10.xml” for example. If not, automatic load at start will not work. To optain proper config name, you can do the program exit and see saved filename in the configs directory.&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== pixet.ini file ==&lt;br /&gt;
This is the main configuration file of the Pixet core. It has several sections beginning with a title in square brackets. Sections contain configuration lines formated as &#039;&#039;&#039;Name=value&#039;&#039;&#039; or &#039;&#039;&#039;Name=&#039;&#039;&#039; for default value. They can also contain comments, which start with a semicolon. This way you can also deactivate some configuration lines.&amp;lt;br&amp;gt;&lt;br /&gt;
Default version of the file conaining used options and all remaining options disabled + with =default. User can edit it and enable.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Up to release 1.8.3 the [Hwlibs] section contains lines without the = symbol. This is not compliant with the INI standard. &#039;&#039;&#039;The file format will change&#039;&#039;&#039; soon. From the next version all data lines will starts with the name=.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The default &#039;&#039;&#039;path where Pixet core looks for the pixet.ini&#039;&#039;&#039; file is the same as the path to the program that started the pxcore library. So the file should be next to it. Attention, &#039;&#039;&#039;all other paths&#039;&#039;&#039; are relative to the current directory, not to the position of the program.&amp;lt;br&amp;gt;&lt;br /&gt;
So if you run c:\program&amp;amp;nbsp;files\pixet\pixet.exe from c:\users\myname, pxcore will try to load c:\program&amp;amp;nbsp;files\pixet\pixet.ini and all other relative paths (including those listed in the pixet.ini) will start with c:\users\myname.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
General settings of used directories, core and the Pixet program parameters:&lt;br /&gt;
* &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; UseAppDataDir=true - Change default location of the configs and logs subdirs and ini files to the user data directory. It also allows different login users to have different settings of same devices in same programs.&lt;br /&gt;
: Note: This does not affects the factory directory.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIniInAppDataDir&#039;&#039;&#039; PixetIniInAppDataDir=true - Enable reading the pixet.ini file from the user data directory. Very usesful if the program is located in the Program files or at other location with no write rights. It also allows different users to have different pixet.ini. Note: Enabling this option means that the Pixet core first loads this file (from the program launch point) and, after detecting this option, loads it again from the user data directory. Other settings in the default pixet.ini are therefore ignored.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIni&#039;&#039;&#039; PixetIni=C:\myPixetAppData\myPixetIni1.ini - Change name and location of the pixet.ini file. Similar to the case of PixetIniInAppDataDir, when using PixetIni=, the initialization file will be loaded again and the contents of the original file will not affect the further operation of the software.&lt;br /&gt;
* &#039;&#039;&#039;AppDataDir&#039;&#039;&#039; AppDataDir=C:\myPixetAppData\group1 - Change location of the user data directory to specified path. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings.&lt;br /&gt;
* &#039;&#039;&#039;ConfigsDir&#039;&#039;&#039; ConfigsDir=C:\myPixetAppData\configsGroup1 - Change location od the configs dir to other location. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings of devices.&lt;br /&gt;
* &#039;&#039;&#039;FactoryDir&#039;&#039;&#039; FactoryDir=C:\myPixetAppData\factory - Change location od the factory dir to other location. Useful if user have many independent places of a programs, creating new programs and testing new devices. User can simply store all factory files in one location. Or it is possible to have such a directory on the company server, where users do not have the right to write.&lt;br /&gt;
* &#039;&#039;&#039;LogsDir&#039;&#039;&#039; LogsDir=C:\temp\pxCoreDebug - Change location of the logs directory. Useful if user have many independent places of a programs, typically if creating new programs. User can simply collect all logs to one directory so that he does not have to open another one every time.&lt;br /&gt;
* &#039;&#039;&#039;Splash&#039;&#039;&#039; Splash=true - Use a splash screen when the Pixet program starting. It does not affect programs using the API.&lt;br /&gt;
* &#039;&#039;&#039;FileDevice&#039;&#039;&#039; FileDevice=true - Enable virtual &amp;quot;file device&amp;quot; independent if physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;FileDeviceWhenNoDevs&#039;&#039;&#039; = FileDeviceWhenNoDevs=false - Disable virtual &amp;quot;file device&amp;quot; if no physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;SaveSettings&#039;&#039;&#039; SaveSettings=false - Disable automatic save device settings on exit pixet core. It affects Pixet as well as programs that use the API.&lt;br /&gt;
* &#039;&#039;&#039;MaxFrameMemory&#039;&#039;&#039; MaxFrameMemory=1024 - Change the frame memory limit for multiframe acquisitions. Reserved for future use, currently not used.&lt;br /&gt;
* &#039;&#039;&#039;MainUi&#039;&#039;&#039; MainUi=devcontrol - Change main user interface plugin of the Pixet program. User can programm your own plugins and one can be used instead of the Pixet main window.&lt;br /&gt;
* &#039;&#039;&#039;LogLeaveOldLogs&#039;&#039;&#039; LogLeaveOldLogs=false - Disable archiving old log files sets.&lt;br /&gt;
* &#039;&#039;&#039;LogRotateCount&#039;&#039;&#039; LogRotateCount=15 - Change number of archived log directories.&lt;br /&gt;
* &#039;&#039;&#039;HighDPI&#039;&#039;&#039; HighDPI=true - Enable AA_EnableHighDpiScaling feature in QT GUI environment. Disable can work only in very old versions of Pixet. Currently is deprecated and allways on.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of hardware library files/paths used in startup to search and connect a devices. See the hwlibs subdirectory description for details.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039; Left is default Pixet configuration with hwlib files in the hwlibs subdirectory, right is simple arrangement with files in the program directory. Last line is disabled in both versions.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section example (dirs/flat structure)&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section (old format, before 2025/09)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\widepix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
;hwlib=hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=minipix.dll&lt;br /&gt;
hwlib=widepix.dll&lt;br /&gt;
hwlib=zem.dll&lt;br /&gt;
;hwlib=zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\widepix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
;hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
minipix.dll&lt;br /&gt;
widepix.dll&lt;br /&gt;
zem.dll&lt;br /&gt;
;zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
User can disable some hwlibs using the ; symbol.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;List of HWLIB files:&#039;&#039;&#039; Windows / Linux&lt;br /&gt;
* &#039;&#039;&#039;Minipix&#039;&#039;&#039;: minipix.dll / minipix.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with Eth&#039;&#039;&#039;: zest.dll / zest.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with USB2&#039;&#039;&#039;: widepix.dll / widepix.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix&#039;&#039;&#039; or &#039;&#039;&#039;Widepix with USB3&#039;&#039;&#039;: zem.dll (and aux. file okFrontPanel.dll - allways in the program directory) / zem.so + okFrontPanel.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix new&#039;&#039;&#039;: abrd-hwlib.dll / abrd-hwlib.so&lt;br /&gt;
* And customer-specific files for motor driving, x-ray sources, etc.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths. All files is by default in the plugins subdirectory.&lt;br /&gt;
; Note&lt;br /&gt;
: Some plugins are not only for GUI Pixet&lt;br /&gt;
: Accessing specific files like as &#039;&#039;&#039;HDF5&#039;&#039;&#039;, &#039;&#039;&#039;TIFF&#039;&#039;&#039;&lt;br /&gt;
: These plugins are also needed when using an API.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[PixelmanPlugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths with backward compatibility for old Pixelman program.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This is very obsolette. Support for Pixelman related stuff (this ini section, file formats, etc) &#039;&#039;&#039;will be removed soon&#039;&#039;&#039; without replacement.&lt;br /&gt;
&lt;br /&gt;
== Device configuration ini files ==&lt;br /&gt;
Some devices can has configuration file. Theese files are located in the program main directory or in the user data directory if the UseAppDataDir=true option used. Files have names identical to the names of the corresponding HWlibs, ending with .ini. For example, the Ethernet Widepix uses HWlib zest.dll (or zest.so on Linux) and the configuration is stored in zest.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is usually no need to edit these files, you can find details about them in the device&#039;s manual.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only for network devices it is sometimes useful to define IP addresses on which Pixet core should search for devices. Either because the general search does not work on the given network, or so that the program does not &amp;quot;steal&amp;quot; a device in another room.&lt;br /&gt;
For example, in zest.ini, each device can has its own section and an IP address defined in it:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini&amp;gt;&lt;br /&gt;
[Device0]&lt;br /&gt;
IP=10.10.1.30&lt;br /&gt;
 &lt;br /&gt;
[Device1]&lt;br /&gt;
IP=10.10.1.31&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Device firmware files ==&lt;br /&gt;
Some devices need firmware files to upload while initialization process. These files are allways located in the program directory. Names are typically composed from HWlib name and readout chip name (zemtpx3.rbf for example).&amp;lt;br&amp;gt;&lt;br /&gt;
List of this kind of files:&amp;lt;br&amp;gt;&lt;br /&gt;
zestwpx.bit, zemwpxf.rbf, zemtpx3.rbf, zemtpx3quad.rbf, zemtpx.rbf, cyptpx3pix.rbf&amp;lt;br&amp;gt;&lt;br /&gt;
Note: The standard Pixet distribution that comes with your device only contains the files for that device, so you usually won&#039;t see all of these files. And Minipix, for example, doesn&#039;t need any of it.&lt;br /&gt;
&lt;br /&gt;
== Insidious complications with files/dirs ==&lt;br /&gt;
Let&#039;s have the following program and with it pypixet.pyd and other necessary files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir(&amp;quot;test-output&amp;quot;)&lt;br /&gt;
import pypixet&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pixet core init...&amp;quot;)&lt;br /&gt;
pypixet.start()&lt;br /&gt;
pixet=pypixet.pixet&lt;br /&gt;
devices = pixet.devices()&lt;br /&gt;
dev = devices[0]&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition (3 frames @ 1 sec) - start&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(3, 1, pixet.PX_FTYPE_AUTODETECT, &amp;quot;example.png&amp;quot;)&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition - end:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
pixet.exitPixet()&lt;br /&gt;
pypixet.exit()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This program normally works with e.g. Minipix, but does not work with e.q. Advapix. Crashes at pypixet.start() or has not any detected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The problem is that hwlibs load their files eg firmware from the current directory. Minipix not need any other files, Advapix need a firmware .rbf file. Moving &#039;&#039;&#039;os.chdir&#039;&#039;&#039; after &#039;&#039;&#039;pypixet.start()&#039;&#039;&#039; solves the problem.&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1725</id>
		<title>Files and directories of the Pixet and SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1725"/>
		<updated>2026-04-24T11:40:47Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* hwlibs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main directory of the Pixet program =&lt;br /&gt;
[[File:Directory-pixet.png|thumb|alt=Pixet main directory if all here|Pixet main directory if all here]]&lt;br /&gt;
Here are main program files, binary libraries, API files, licence file and the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; file. Here may also be hwlibs subdirectory, special files for some devices. Their location depends on the &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
There can also be subdirectories factory, configs and logs. They are there if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is disabled in &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section.&amp;lt;br&amp;gt;&lt;br /&gt;
If here are not located configs, inis and logs, this directory can be located in Program files, or in another location where the user cannot normally write.&lt;br /&gt;
&lt;br /&gt;
; Warning&lt;br /&gt;
: It may be confusing that this directory contains device ini files, such as zest.ini, dummy.ini, ..., since installation, but if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is enabled or &#039;&#039;&#039;AppDataDir&#039;&#039;&#039;= is set, in pixet.ini, the files located here have no effect on the devices.&lt;br /&gt;
&lt;br /&gt;
= User data directory =&lt;br /&gt;
This is location of [[#The factory and the configs subdirectories|configuration]] and [[#logs|log]] files. The program must be able to write here.&amp;lt;br&amp;gt;&lt;br /&gt;
This is used, if in the &#039;&#039;&#039;[[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|pixet.ini]]&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section is located &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; (default state).&lt;br /&gt;
[[File:Directory-appdata.png|thumb|alt=AppData - user data directory|AppData - user data directory]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Default location is in the user&#039;s system application data directory, like us:&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Windows&#039;&#039;&#039; C:\Users\username\AppData\Local\PixetPro&lt;br /&gt;
* &#039;&#039;&#039;Linux&#039;&#039;&#039; ~/.config/PixetPro&lt;br /&gt;
* &#039;&#039;&#039;MacOS&#039;&#039;&#039; ~/Library/Application Support/PixetPro&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
* Location of the directory can be changed anywhere, using the &#039;&#039;&#039;AppDataDir=&#039;&#039;&#039; line in the pixet.ini.&lt;br /&gt;
* Turning on &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; does not affect the &#039;&#039;&#039;factory&#039;&#039;&#039; directory. If it is not changed using &#039;&#039;&#039;factoryDir=&#039;&#039;&#039;, it is still expected beside the running program, or in the current directory, if different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;: [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
= Subdirectories of the Pixet program =&lt;br /&gt;
&lt;br /&gt;
== The factory and the configs subdirectories ==&lt;br /&gt;
The factory directory should contain the factory default configuration XML files.&lt;br /&gt;
The Pixet core use it while starting, if the configuration file is not in the configs directory.&lt;br /&gt;
The configs directory contain configuration XML files.&lt;br /&gt;
The Pixet core try to use it while starting and save the current settings to it, if exiting.&amp;lt;br&amp;gt;&lt;br /&gt;
(This process works the same way when you start and quit the Pixet program or if you use C API functions pxcInit/pxcExit or Python API functions pypixet.start() / pixet.exitPixet()+pypixet.exit().)&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#Configuration XML files]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdirs can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== factory ===&lt;br /&gt;
It should contain the factory default configuration XML files. The Pixet core use it while starting, if the configuration file is not in the configs directory or if user click the &amp;quot;Load factory config&amp;quot; or scripts can use it by the loadFactoryConfig() method.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or can be located anywhere using the &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
Hint: If you frequently do experiments with more instances of Pixet, API-using programs or scripts and have more devices, you can use single location of the factory directory for all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Location of this directory &#039;&#039;&#039;not affected by&#039;&#039;&#039; the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini.&lt;br /&gt;
* File &#039;&#039;&#039;names must be exact&#039;&#039;&#039;, for example MiniPIX-D06-W0065.xml, AdvaPIX-C06-W0127-4.xml. It is the complete device name, where all spaces are replaced by minuses. If not exact, a load-factory like functions cannot find it.&lt;br /&gt;
&lt;br /&gt;
=== configs ===&lt;br /&gt;
Contain &#039;&#039;&#039;configuration XML files for devices&#039;&#039;&#039;. The Pixet core try to use it while starting the Pixet program or in pypixet.start() method in scripts, or if the C API function pxcInit() used. And automatically save the current settings to it, while exitting the Pixet program, or if the pypixet.exit() method is used in scripts, or if the pxcExit() function used via C API.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In addition, this directory contains:&lt;br /&gt;
* &#039;&#039;&#039;Configuration XML files for filters&#039;&#039;&#039; - name format filtername_DevName ChipID.xml - for example &amp;quot;adaptiveff_MiniPIX D06-W0065.xml&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins - dev specific&#039;&#039;&#039; - name format pluginname_ChipID.ini - for example &amp;quot;devcontrol_D06-W0065.ini&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins&#039;&#039;&#039; - name format pluginname.ini - for example &amp;quot;pyscripting.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;ConfigsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
== logs ==&lt;br /&gt;
[[File:Directory-logs.png|thumb|alt=The logs directory|The logs directory]]&lt;br /&gt;
Here are log files from all hardware libraries, pixet core. Files are from last Pixet core run. While next run, the core archive last log files. Subdirectories logs1, logs2, ... contains backups for last 10 sessions.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;LogsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
* Main log file is the &#039;&#039;&#039;log.log&#039;&#039;&#039;. This is the main log of the Pixet core.&lt;br /&gt;
:: You can see here the attempts to load hwlibs, whether any device was found, whether hwlib was able to start, load the configuration, ...&lt;br /&gt;
* Hwlib logs are named by each hwlib, eq. &#039;&#039;&#039;minipix.log&#039;&#039;&#039;.&lt;br /&gt;
:: You can see here the hwlib messages. It contains detected device names, serial numbers and types.&lt;br /&gt;
* Device logs are named by hwlib and each device, eq. &#039;&#039;&#039;minipixtpx3_0144 A.log&#039;&#039;&#039;.&lt;br /&gt;
:: Here are the low-level informations. It can be helpful for our Technical support if the device is naughty.&lt;br /&gt;
* The &#039;&#039;&#039;runtime.log&#039;&#039;&#039;.&lt;br /&gt;
:: Simple list of init/exit times of the Pixet core.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
== hwlibs ==&lt;br /&gt;
This is the usual place for hwlib libraries, designed to work with different types of devices. The actual location of the files is defined in the &amp;lt;nowiki&amp;gt;[hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file. Default is the hwlibs subdirectory of the main program running directory. But here are a simple relative paths from the main program location and can be configured without subdirectory. It is commonly used in single-purpose programs using API.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
== plugins ==&lt;br /&gt;
Default location of plugins to the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Some plugins can be need for API too.&lt;br /&gt;
&lt;br /&gt;
== drivers ==&lt;br /&gt;
Installators of drivers for some devices.&lt;br /&gt;
&lt;br /&gt;
== libs ==&lt;br /&gt;
Libraries for Python scripting plugin.&lt;br /&gt;
&lt;br /&gt;
== scripts ==&lt;br /&gt;
* Sample scripts for using Python scripting plugin.&lt;br /&gt;
* The default place to search for imports used in scripts run from the Python scripting plugin. &lt;br /&gt;
&lt;br /&gt;
== Other subdirs ==&lt;br /&gt;
* samples - Sample data for demo when using virtual file device.&lt;br /&gt;
* help - PDF manuals&lt;br /&gt;
* platforms, styles - System directories of QT.&lt;br /&gt;
&lt;br /&gt;
= Main directory of the API-using programs, independent on the Pixet =&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio files installed|Directory of minimalistic program using binary API and working on computer with Visual Studio installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
User can write programs using our API. To operate them, need:&lt;br /&gt;
* &#039;&#039;&#039;Pixet core library&#039;&#039;&#039; - The core of the Pixet program. &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039;, or pxcore.so file.&lt;br /&gt;
* &#039;&#039;&#039;Pixel processing library&#039;&#039;&#039; - &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or pxproc.so library - only for Clustering and Spectral imaging use&lt;br /&gt;
* &#039;&#039;&#039;Static linking libraries&#039;&#039;&#039; - To compile binary programs on Windows, user need the pxcore.lib (and pxproc.lib). Only in compile time. Compiler must be setup for using it.&lt;br /&gt;
* &#039;&#039;&#039;Auxilliary libraries of system&#039;&#039;&#039; - If program must working on computer without an IDE installed, can need some auxilliary libs, like as: msvcp140.dll, vcruntime140.dll, etc&lt;br /&gt;
* &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; - configuration for the Pixet core. See [[#pixet.ini file]]&lt;br /&gt;
* &#039;&#039;&#039;HWlibs&#039;&#039;&#039; for the given hardware (and firmwares if devices need). See [[#hwlibs]] and [[#Device firmware files]]&lt;br /&gt;
* &#039;&#039;&#039;Device configuration files&#039;&#039;&#039; in the &#039;&#039;&#039;factory&#039;&#039;&#039; and &#039;&#039;&#039;configs&#039;&#039;&#039; directories, or elsewhere according to the settings in pixet.ini. See [[#The factory and the configs subdirectories]]&lt;br /&gt;
* &#039;&#039;&#039;Place for logs&#039;&#039;&#039; in the &#039;&#039;&#039;logs&#039;&#039;&#039; directory, or elsewhere according to the settings in pixet.ini. See [[#logs]]&lt;br /&gt;
* &#039;&#039;&#039;Python interface&#039;&#039;&#039; - To run Python scripts, &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; is needed in addition. And a &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; for Clustering and Spectral imaging objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basic files are in the API packages:&lt;br /&gt;
{{APIpackages}}&lt;br /&gt;
&lt;br /&gt;
Alternatives to run the API using programs:&lt;br /&gt;
# Copy all need files to the Project directory.&lt;br /&gt;
# While running the program, change the operating directory to the Pixet main directory.&lt;br /&gt;
# Copy the binary executable or python script to the Pixet main directory and run it from here. Useful for occasional single test, but can do problems in more extensive cases.&lt;br /&gt;
&lt;br /&gt;
= Special files =&lt;br /&gt;
&lt;br /&gt;
=== Configuration XML files ===&lt;br /&gt;
The config file contains all detector settings and you can start and continue with the settings as it was while last program exit. The factory config is config saved afther low-level detector setup, finding of bad pixels, calibrations and other factory tests.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&lt;br /&gt;
* The files must have proper names. “WidePIX-B04-W0535-10.xml” for example. If not, automatic load at start will not work. To optain proper config name, you can do the program exit and see saved filename in the configs directory.&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== pixet.ini file ==&lt;br /&gt;
This is the main configuration file of the Pixet core. It has several sections beginning with a title in square brackets. Sections contain configuration lines formated as &#039;&#039;&#039;Name=value&#039;&#039;&#039; or &#039;&#039;&#039;Name=&#039;&#039;&#039; for default value. They can also contain comments, which start with a semicolon. This way you can also deactivate some configuration lines.&amp;lt;br&amp;gt;&lt;br /&gt;
Default version of the file conaining used options and all remaining options disabled + with =default. User can edit it and enable.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Up to release 1.8.3 the [Hwlibs] section contains lines without the = symbol. This is not compliant with the INI standard. &#039;&#039;&#039;The file format will change&#039;&#039;&#039; soon. From the next version all data lines will starts with the name=.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The default &#039;&#039;&#039;path where Pixet core looks for the pixet.ini&#039;&#039;&#039; file is the same as the path to the program that started the pxcore library. So the file should be next to it. Attention, &#039;&#039;&#039;all other paths&#039;&#039;&#039; are relative to the current directory, not to the position of the program.&amp;lt;br&amp;gt;&lt;br /&gt;
So if you run c:\program&amp;amp;nbsp;files\pixet\pixet.exe from c:\users\myname, pxcore will try to load c:\program&amp;amp;nbsp;files\pixet\pixet.ini and all other relative paths (including those listed in the pixet.ini) will start with c:\users\myname.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
General settings of used directories, core and the Pixet program parameters:&lt;br /&gt;
* &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; UseAppDataDir=true - Change default location of the configs and logs subdirs and ini files to the user data directory. It also allows different login users to have different settings of same devices in same programs.&lt;br /&gt;
: Note: This does not affects the factory directory.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIniInAppDataDir&#039;&#039;&#039; PixetIniInAppDataDir=true - Enable reading the pixet.ini file from the user data directory. Very usesful if the program is located in the Program files or at other location with no write rights. It also allows different users to have different pixet.ini. Note: Enabling this option means that the Pixet core first loads this file (from the program launch point) and, after detecting this option, loads it again from the user data directory. Other settings in the default pixet.ini are therefore ignored.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIni&#039;&#039;&#039; PixetIni=C:\myPixetAppData\myPixetIni1.ini - Change name and location of the pixet.ini file. Similar to the case of PixetIniInAppDataDir, when using PixetIni=, the initialization file will be loaded again and the contents of the original file will not affect the further operation of the software.&lt;br /&gt;
* &#039;&#039;&#039;AppDataDir&#039;&#039;&#039; AppDataDir=C:\myPixetAppData\group1 - Change location of the user data directory to specified path. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings.&lt;br /&gt;
* &#039;&#039;&#039;ConfigsDir&#039;&#039;&#039; ConfigsDir=C:\myPixetAppData\configsGroup1 - Change location od the configs dir to other location. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings of devices.&lt;br /&gt;
* &#039;&#039;&#039;FactoryDir&#039;&#039;&#039; FactoryDir=C:\myPixetAppData\factory - Change location od the factory dir to other location. Useful if user have many independent places of a programs, creating new programs and testing new devices. User can simply store all factory files in one location. Or it is possible to have such a directory on the company server, where users do not have the right to write.&lt;br /&gt;
* &#039;&#039;&#039;LogsDir&#039;&#039;&#039; LogsDir=C:\temp\pxCoreDebug - Change location of the logs directory. Useful if user have many independent places of a programs, typically if creating new programs. User can simply collect all logs to one directory so that he does not have to open another one every time.&lt;br /&gt;
* &#039;&#039;&#039;Splash&#039;&#039;&#039; Splash=true - Use a splash screen when the Pixet program starting. It does not affect programs using the API.&lt;br /&gt;
* &#039;&#039;&#039;FileDevice&#039;&#039;&#039; FileDevice=true - Enable virtual &amp;quot;file device&amp;quot; independent if physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;FileDeviceWhenNoDevs&#039;&#039;&#039; = FileDeviceWhenNoDevs=false - Disable virtual &amp;quot;file device&amp;quot; if no physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;SaveSettings&#039;&#039;&#039; SaveSettings=false - Disable automatic save device settings on exit pixet core. It affects Pixet as well as programs that use the API.&lt;br /&gt;
* &#039;&#039;&#039;MaxFrameMemory&#039;&#039;&#039; MaxFrameMemory=1024 - Change the frame memory limit for multiframe acquisitions. Reserved for future use, currently not used.&lt;br /&gt;
* &#039;&#039;&#039;MainUi&#039;&#039;&#039; MainUi=devcontrol - Change main user interface plugin of the Pixet program. User can programm your own plugins and one can be used instead of the Pixet main window.&lt;br /&gt;
* &#039;&#039;&#039;LogLeaveOldLogs&#039;&#039;&#039; LogLeaveOldLogs=false - Disable archiving old log files sets.&lt;br /&gt;
* &#039;&#039;&#039;LogRotateCount&#039;&#039;&#039; LogRotateCount=15 - Change number of archived log directories.&lt;br /&gt;
* &#039;&#039;&#039;HighDPI&#039;&#039;&#039; HighDPI=true - Enable AA_EnableHighDpiScaling feature in QT GUI environment. Disable can work only in very old versions of Pixet. Currently is deprecated and allways on.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of hardware library files/paths used in startup to search and connect a devices. See the hwlibs subdirectory description for details.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039; Left is default Pixet configuration with hwlib files in the hwlibs subdirectory, right is simple arrangement with files in the program directory. Last line is disabled in both versions.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section example (dirs/flat structure)&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section (old format, before 2025/09)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\widepix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
;hwlib=hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=minipix.dll&lt;br /&gt;
hwlib=widepix.dll&lt;br /&gt;
hwlib=zem.dll&lt;br /&gt;
;hwlib=zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\widepix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
;hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
minipix.dll&lt;br /&gt;
widepix.dll&lt;br /&gt;
zem.dll&lt;br /&gt;
;zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
User can disable some hwlibs using the ; symbol.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;List of HWLIB files:&#039;&#039;&#039; Windows / Linux&lt;br /&gt;
* &#039;&#039;&#039;Minipix&#039;&#039;&#039;: minipix.dll / minipix.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with Eth&#039;&#039;&#039;: zest.dll / zest.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with USB2&#039;&#039;&#039;: widepix.dll / widepix.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix&#039;&#039;&#039; or &#039;&#039;&#039;Widepix with USB3&#039;&#039;&#039;: zem.dll (and aux. file okFrontPanel.dll - allways in the program directory) / zem.so + okFrontPanel.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix new&#039;&#039;&#039;: abrd-hwlib.dll / abrd-hwlib.so&lt;br /&gt;
* And customer-specific files for motor driving, x-ray sources, etc.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths. All files is by default in the plugins subdirectory.&lt;br /&gt;
; Note&lt;br /&gt;
: Some plugins are not only for GUI Pixet&lt;br /&gt;
: Accessing specific files like as &#039;&#039;&#039;HDF5&#039;&#039;&#039;, &#039;&#039;&#039;TIFF&#039;&#039;&#039;&lt;br /&gt;
: These plugins are also needed when using an API.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[PixelmanPlugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths with backward compatibility for old Pixelman program.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This is very obsolette. Support for Pixelman related stuff (this ini section, file formats, etc) &#039;&#039;&#039;will be removed soon&#039;&#039;&#039; without replacement.&lt;br /&gt;
&lt;br /&gt;
== Device configuration ini files ==&lt;br /&gt;
Some devices can has configuration file. Theese files are located in the program main directory or in the user data directory if the UseAppDataDir=true option used. Files have names identical to the names of the corresponding HWlibs, ending with .ini. For example, the Ethernet Widepix uses HWlib zest.dll (or zest.so on Linux) and the configuration is stored in zest.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is usually no need to edit these files, you can find details about them in the device&#039;s manual.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only for network devices it is sometimes useful to define IP addresses on which Pixet core should search for devices. Either because the general search does not work on the given network, or so that the program does not &amp;quot;steal&amp;quot; a device in another room.&lt;br /&gt;
For example, in zest.ini, each device can has its own section and an IP address defined in it:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini&amp;gt;&lt;br /&gt;
[Device0]&lt;br /&gt;
IP=10.10.1.30&lt;br /&gt;
 &lt;br /&gt;
[Device1]&lt;br /&gt;
IP=10.10.1.31&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Device firmware files ==&lt;br /&gt;
Some devices need firmware files to upload while initialization process. These files are allways located in the program directory. Names are typically composed from HWlib name and readout chip name (zemtpx3.rbf for example).&amp;lt;br&amp;gt;&lt;br /&gt;
List of this kind of files:&amp;lt;br&amp;gt;&lt;br /&gt;
zestwpx.bit, zemwpxf.rbf, zemtpx3.rbf, zemtpx3quad.rbf, zemtpx.rbf, cyptpx3pix.rbf&amp;lt;br&amp;gt;&lt;br /&gt;
Note: The standard Pixet distribution that comes with your device only contains the files for that device, so you usually won&#039;t see all of these files. And Minipix, for example, doesn&#039;t need any of it.&lt;br /&gt;
&lt;br /&gt;
== Insidious complications with files/dirs ==&lt;br /&gt;
Let&#039;s have the following program and with it pypixet.pyd and other necessary files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir(&amp;quot;test-output&amp;quot;)&lt;br /&gt;
import pypixet&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pixet core init...&amp;quot;)&lt;br /&gt;
pypixet.start()&lt;br /&gt;
pixet=pypixet.pixet&lt;br /&gt;
devices = pixet.devices()&lt;br /&gt;
dev = devices[0]&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition (3 frames @ 1 sec) - start&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(3, 1, pixet.PX_FTYPE_AUTODETECT, &amp;quot;example.png&amp;quot;)&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition - end:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
pixet.exitPixet()&lt;br /&gt;
pypixet.exit()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This program normally works with e.g. Minipix, but does not work with e.q. Advapix. Crashes at pypixet.start() or has not any detected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The problem is that hwlibs load their files eg firmware from the current directory. Minipix not need any other files, Advapix need a firmware .rbf file. Moving &#039;&#039;&#039;os.chdir&#039;&#039;&#039; after &#039;&#039;&#039;pypixet.start()&#039;&#039;&#039; solves the problem.&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1724</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1724"/>
		<updated>2026-04-22T13:09:34Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Frame measuring and related functions list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 30;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1723</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1723"/>
		<updated>2026-04-21T11:38:41Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1722</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1722"/>
		<updated>2026-04-21T11:37:49Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Smaller blocks can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1721</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1721"/>
		<updated>2026-04-21T11:18:19Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: Testing feature, t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1720</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1720"/>
		<updated>2026-04-21T11:11:57Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;Store trigger events to data. If enabled, trigger events will stored to the data as pixel with Overflow=10. See [[File_types#T3PA_files_details|T3PA files_details]]&amp;lt;br&amp;gt;Note: t3pa-like ASCII line used in all file formats, including binary. || [bool]&amp;lt;br&amp;gt;default 0 || [bool]&amp;lt;br&amp;gt;default 0&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1719</id>
		<title>Files and directories of the Pixet and SDK</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Files_and_directories_of_the_Pixet_and_SDK&amp;diff=1719"/>
		<updated>2026-04-21T08:53:55Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* factory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main directory of the Pixet program =&lt;br /&gt;
[[File:Directory-pixet.png|thumb|alt=Pixet main directory if all here|Pixet main directory if all here]]&lt;br /&gt;
Here are main program files, binary libraries, API files, licence file and the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; file. Here may also be hwlibs subdirectory, special files for some devices. Their location depends on the &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
There can also be subdirectories factory, configs and logs. They are there if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is disabled in &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section.&amp;lt;br&amp;gt;&lt;br /&gt;
If here are not located configs, inis and logs, this directory can be located in Program files, or in another location where the user cannot normally write.&lt;br /&gt;
&lt;br /&gt;
; Warning&lt;br /&gt;
: It may be confusing that this directory contains device ini files, such as zest.ini, dummy.ini, ..., since installation, but if &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; is enabled or &#039;&#039;&#039;AppDataDir&#039;&#039;&#039;= is set, in pixet.ini, the files located here have no effect on the devices.&lt;br /&gt;
&lt;br /&gt;
= User data directory =&lt;br /&gt;
This is location of [[#The factory and the configs subdirectories|configuration]] and [[#logs|log]] files. The program must be able to write here.&amp;lt;br&amp;gt;&lt;br /&gt;
This is used, if in the &#039;&#039;&#039;[[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|pixet.ini]]&#039;&#039;&#039;, in the &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; section is located &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; (default state).&lt;br /&gt;
[[File:Directory-appdata.png|thumb|alt=AppData - user data directory|AppData - user data directory]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Default location is in the user&#039;s system application data directory, like us:&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Windows&#039;&#039;&#039; C:\Users\username\AppData\Local\PixetPro&lt;br /&gt;
* &#039;&#039;&#039;Linux&#039;&#039;&#039; ~/.config/PixetPro&lt;br /&gt;
* &#039;&#039;&#039;MacOS&#039;&#039;&#039; ~/Library/Application Support/PixetPro&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
* Location of the directory can be changed anywhere, using the &#039;&#039;&#039;AppDataDir=&#039;&#039;&#039; line in the pixet.ini.&lt;br /&gt;
* Turning on &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; does not affect the &#039;&#039;&#039;factory&#039;&#039;&#039; directory. If it is not changed using &#039;&#039;&#039;factoryDir=&#039;&#039;&#039;, it is still expected beside the running program, or in the current directory, if different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;: [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
= Subdirectories of the Pixet program =&lt;br /&gt;
&lt;br /&gt;
== The factory and the configs subdirectories ==&lt;br /&gt;
The factory directory should contain the factory default configuration XML files.&lt;br /&gt;
The Pixet core use it while starting, if the configuration file is not in the configs directory.&lt;br /&gt;
The configs directory contain configuration XML files.&lt;br /&gt;
The Pixet core try to use it while starting and save the current settings to it, if exiting.&amp;lt;br&amp;gt;&lt;br /&gt;
(This process works the same way when you start and quit the Pixet program or if you use C API functions pxcInit/pxcExit or Python API functions pypixet.start() / pixet.exitPixet()+pypixet.exit().)&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#Configuration XML files]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdirs can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== factory ===&lt;br /&gt;
It should contain the factory default configuration XML files. The Pixet core use it while starting, if the configuration file is not in the configs directory or if user click the &amp;quot;Load factory config&amp;quot; or scripts can use it by the loadFactoryConfig() method.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or can be located anywhere using the &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; line in the pixet.ini file.&amp;lt;br&amp;gt;&lt;br /&gt;
Hint: If you frequently do experiments with more instances of Pixet, API-using programs or scripts and have more devices, you can use single location of the factory directory for all.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Location of this directory &#039;&#039;&#039;not affected by&#039;&#039;&#039; the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini.&lt;br /&gt;
* File &#039;&#039;&#039;names must be exact&#039;&#039;&#039;, for example MiniPIX-D06-W0065.xml, AdvaPIX-C06-W0127-4.xml. It is the complete device name, where all spaces are replaced by minuses. If not exact, a load-factory like functions cannot find it.&lt;br /&gt;
&lt;br /&gt;
=== configs ===&lt;br /&gt;
Contain &#039;&#039;&#039;configuration XML files for devices&#039;&#039;&#039;. The Pixet core try to use it while starting the Pixet program or in pypixet.start() method in scripts, or if the C API function pxcInit() used. And automatically save the current settings to it, while exitting the Pixet program, or if the pypixet.exit() method is used in scripts, or if the pxcExit() function used via C API.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In addition, this directory contains:&lt;br /&gt;
* &#039;&#039;&#039;Configuration XML files for filters&#039;&#039;&#039; - name format filtername_DevName ChipID.xml - for example &amp;quot;adaptiveff_MiniPIX D06-W0065.xml&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins - dev specific&#039;&#039;&#039; - name format pluginname_ChipID.ini - for example &amp;quot;devcontrol_D06-W0065.ini&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;Configuration INI files for plugins&#039;&#039;&#039; - name format pluginname.ini - for example &amp;quot;pyscripting.ini&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;ConfigsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
== logs ==&lt;br /&gt;
[[File:Directory-logs.png|thumb|alt=The logs directory|The logs directory]]&lt;br /&gt;
Here are log files from all hardware libraries, pixet core. Files are from last Pixet core run. While next run, the core archive last log files. Subdirectories logs1, logs2, ... contains backups for last 10 sessions.&amp;lt;br&amp;gt;&lt;br /&gt;
Location of this subdir can be in the main program directory or in user data directory, depending on the &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; line in the pixet.ini file, or can be located anywhere using the &#039;&#039;&#039;LogsDir=&#039;&#039;&#039; line in the pixet.ini file.&lt;br /&gt;
&lt;br /&gt;
* Main log file is the &#039;&#039;&#039;log.log&#039;&#039;&#039;. This is the main log of the Pixet core.&lt;br /&gt;
:: You can see here the attempts to load hwlibs, whether any device was found, whether hwlib was able to start, load the configuration, ...&lt;br /&gt;
* Hwlib logs are named by each hwlib, eq. &#039;&#039;&#039;minipix.log&#039;&#039;&#039;.&lt;br /&gt;
:: You can see here the hwlib messages. It contains detected device names, serial numbers and types.&lt;br /&gt;
* Device logs are named by hwlib and each device, eq. &#039;&#039;&#039;minipixtpx3_0144 A.log&#039;&#039;&#039;.&lt;br /&gt;
:: Here are the low-level informations. It can be helpful for our Technical support if the device is naughty.&lt;br /&gt;
* The &#039;&#039;&#039;runtime.log&#039;&#039;&#039;.&lt;br /&gt;
:: Simple list of init/exit times of the Pixet core.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
== hwlibs ==&lt;br /&gt;
This is the usual place for hwlib libraries, designed to work with different types of devices. The actual location of the files is defined in the &amp;lt;nowiki&amp;gt;[hwlibs]&amp;lt;/nowiki&amp;gt; section of the pixet.ini file. Default is the hwlibs subdirectory of the main program running directory. But here are a simple relative paths from the main program location and can be configured without subdirectory. It is commonly used in single-purpose programs using API.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The default &#039;&#039;&#039;UseAppDataDir=&#039;&#039;&#039; in pixet.ini is &#039;&#039;&#039;enabled in Pixet&#039;&#039;&#039; installation, but &#039;&#039;&#039;disabled in API&#039;&#039;&#039; package.&lt;br /&gt;
&lt;br /&gt;
See [[#pixet.ini file]]&lt;br /&gt;
&lt;br /&gt;
== plugins ==&lt;br /&gt;
Default location of plugins to the Pixet program.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Some plugins can be need for API too.&lt;br /&gt;
&lt;br /&gt;
== drivers ==&lt;br /&gt;
Installators of drivers for some devices.&lt;br /&gt;
&lt;br /&gt;
== libs ==&lt;br /&gt;
Libraries for Python scripting plugin.&lt;br /&gt;
&lt;br /&gt;
== scripts ==&lt;br /&gt;
* Sample scripts for using Python scripting plugin.&lt;br /&gt;
* The default place to search for imports used in scripts run from the Python scripting plugin. &lt;br /&gt;
&lt;br /&gt;
== Other subdirs ==&lt;br /&gt;
* samples - Sample data for demo when using virtual file device.&lt;br /&gt;
* help - PDF manuals&lt;br /&gt;
* platforms, styles - System directories of QT.&lt;br /&gt;
&lt;br /&gt;
= Main directory of the API-using programs, independent on the Pixet =&lt;br /&gt;
[[File:Dirrectory-minimalistic-api-prg-2025.png|frame|right|alt=Directory of minimalistic program using binary API and working on computer with Visual Studio files installed|Directory of minimalistic program using binary API and working on computer with Visual Studio installed&amp;lt;br&amp;gt;(This is afther 2025.09 / for old see: [https://wiki.advacam.cz/wiki/File:Dirrectory-minimalistic-api-prg.png old version])]]&lt;br /&gt;
User can write programs using our API. To operate them, need:&lt;br /&gt;
* &#039;&#039;&#039;Pixet core library&#039;&#039;&#039; - The core of the Pixet program. &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039;, or pxcore.so file.&lt;br /&gt;
* &#039;&#039;&#039;Pixel processing library&#039;&#039;&#039; - &#039;&#039;&#039;pxproc.dll&#039;&#039;&#039; or pxproc.so library - only for Clustering and Spectral imaging use&lt;br /&gt;
* &#039;&#039;&#039;Static linking libraries&#039;&#039;&#039; - To compile binary programs on Windows, user need the pxcore.lib (and pxproc.lib). Only in compile time. Compiler must be setup for using it.&lt;br /&gt;
* &#039;&#039;&#039;Auxilliary libraries of system&#039;&#039;&#039; - If program must working on computer without an IDE installed, can need some auxilliary libs, like as: msvcp140.dll, vcruntime140.dll, etc&lt;br /&gt;
* &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; - configuration for the Pixet core. See [[#pixet.ini file]]&lt;br /&gt;
* &#039;&#039;&#039;HWlibs&#039;&#039;&#039; for the given hardware (and firmwares if devices need). See [[#hwlibs]] and [[#Device firmware files]]&lt;br /&gt;
* &#039;&#039;&#039;Device configuration files&#039;&#039;&#039; in the &#039;&#039;&#039;factory&#039;&#039;&#039; and &#039;&#039;&#039;configs&#039;&#039;&#039; directories, or elsewhere according to the settings in pixet.ini. See [[#The factory and the configs subdirectories]]&lt;br /&gt;
* &#039;&#039;&#039;Place for logs&#039;&#039;&#039; in the &#039;&#039;&#039;logs&#039;&#039;&#039; directory, or elsewhere according to the settings in pixet.ini. See [[#logs]]&lt;br /&gt;
* &#039;&#039;&#039;Python interface&#039;&#039;&#039; - To run Python scripts, &#039;&#039;&#039;pypixet.pyd&#039;&#039;&#039; is needed in addition. And a &#039;&#039;&#039;pypxproc.pyd&#039;&#039;&#039; for Clustering and Spectral imaging objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Basic files are in the API packages:&lt;br /&gt;
{{APIpackages}}&lt;br /&gt;
&lt;br /&gt;
Alternatives to run the API using programs:&lt;br /&gt;
# Copy all need files to the Project directory.&lt;br /&gt;
# While running the program, change the operating directory to the Pixet main directory.&lt;br /&gt;
# Copy the binary executable or python script to the Pixet main directory and run it from here. Useful for occasional single test, but can do problems in more extensive cases.&lt;br /&gt;
&lt;br /&gt;
= Special files =&lt;br /&gt;
&lt;br /&gt;
=== Configuration XML files ===&lt;br /&gt;
The config file contains all detector settings and you can start and continue with the settings as it was while last program exit. The factory config is config saved afther low-level detector setup, finding of bad pixels, calibrations and other factory tests.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;The detector cannot work properly if proper config not loaded&#039;&#039;&#039;.&lt;br /&gt;
* The files must have proper names. “WidePIX-B04-W0535-10.xml” for example. If not, automatic load at start will not work. To optain proper config name, you can do the program exit and see saved filename in the configs directory.&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== pixet.ini file ==&lt;br /&gt;
This is the main configuration file of the Pixet core. It has several sections beginning with a title in square brackets. Sections contain configuration lines formated as &#039;&#039;&#039;Name=value&#039;&#039;&#039; or &#039;&#039;&#039;Name=&#039;&#039;&#039; for default value. They can also contain comments, which start with a semicolon. This way you can also deactivate some configuration lines.&amp;lt;br&amp;gt;&lt;br /&gt;
Default version of the file conaining used options and all remaining options disabled + with =default. User can edit it and enable.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Up to release 1.8.3 the [Hwlibs] section contains lines without the = symbol. This is not compliant with the INI standard. &#039;&#039;&#039;The file format will change&#039;&#039;&#039; soon. From the next version all data lines will starts with the name=.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The default &#039;&#039;&#039;path where Pixet core looks for the pixet.ini&#039;&#039;&#039; file is the same as the path to the program that started the pxcore library. So the file should be next to it. Attention, &#039;&#039;&#039;all other paths&#039;&#039;&#039; are relative to the current directory, not to the position of the program.&amp;lt;br&amp;gt;&lt;br /&gt;
So if you run c:\program&amp;amp;nbsp;files\pixet\pixet.exe from c:\users\myname, pxcore will try to load c:\program&amp;amp;nbsp;files\pixet\pixet.ini and all other relative paths (including those listed in the pixet.ini) will start with c:\users\myname.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Settings]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
General settings of used directories, core and the Pixet program parameters:&lt;br /&gt;
* &#039;&#039;&#039;UseAppDataDir&#039;&#039;&#039; UseAppDataDir=true - Change default location of the configs and logs subdirs and ini files to the user data directory. It also allows different login users to have different settings of same devices in same programs.&lt;br /&gt;
: Note: This does not affects the factory directory.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIniInAppDataDir&#039;&#039;&#039; PixetIniInAppDataDir=true - Enable reading the pixet.ini file from the user data directory. Very usesful if the program is located in the Program files or at other location with no write rights. It also allows different users to have different pixet.ini. Note: Enabling this option means that the Pixet core first loads this file (from the program launch point) and, after detecting this option, loads it again from the user data directory. Other settings in the default pixet.ini are therefore ignored.&lt;br /&gt;
: See: [[#User data directory|&#039;&#039;&#039;User data directory&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;PixetIni&#039;&#039;&#039; PixetIni=C:\myPixetAppData\myPixetIni1.ini - Change name and location of the pixet.ini file. Similar to the case of PixetIniInAppDataDir, when using PixetIni=, the initialization file will be loaded again and the contents of the original file will not affect the further operation of the software.&lt;br /&gt;
* &#039;&#039;&#039;AppDataDir&#039;&#039;&#039; AppDataDir=C:\myPixetAppData\group1 - Change location of the user data directory to specified path. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings.&lt;br /&gt;
* &#039;&#039;&#039;ConfigsDir&#039;&#039;&#039; ConfigsDir=C:\myPixetAppData\configsGroup1 - Change location od the configs dir to other location. Useful if user have more programs using a Advacam devices and want divide it to some groups with different settings of devices.&lt;br /&gt;
* &#039;&#039;&#039;FactoryDir&#039;&#039;&#039; FactoryDir=C:\myPixetAppData\factory - Change location od the factory dir to other location. Useful if user have many independent places of a programs, creating new programs and testing new devices. User can simply store all factory files in one location. Or it is possible to have such a directory on the company server, where users do not have the right to write.&lt;br /&gt;
* &#039;&#039;&#039;LogsDir&#039;&#039;&#039; LogsDir=C:\temp\pxCoreDebug - Change location of the logs directory. Useful if user have many independent places of a programs, typically if creating new programs. User can simply collect all logs to one directory so that he does not have to open another one every time.&lt;br /&gt;
* &#039;&#039;&#039;Splash&#039;&#039;&#039; Splash=true - Use a splash screen when the Pixet program starting. It does not affect programs using the API.&lt;br /&gt;
* &#039;&#039;&#039;FileDevice&#039;&#039;&#039; FileDevice=true - Enable virtual &amp;quot;file device&amp;quot; independent if physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;FileDeviceWhenNoDevs&#039;&#039;&#039; = FileDeviceWhenNoDevs=false - Disable virtual &amp;quot;file device&amp;quot; if no physical devices connected.&lt;br /&gt;
: See: [[Devices_support#File_device|&#039;&#039;&#039;File device&#039;&#039;&#039;]]&lt;br /&gt;
* &#039;&#039;&#039;SaveSettings&#039;&#039;&#039; SaveSettings=false - Disable automatic save device settings on exit pixet core. It affects Pixet as well as programs that use the API.&lt;br /&gt;
* &#039;&#039;&#039;MaxFrameMemory&#039;&#039;&#039; MaxFrameMemory=1024 - Change the frame memory limit for multiframe acquisitions. Reserved for future use, currently not used.&lt;br /&gt;
* &#039;&#039;&#039;MainUi&#039;&#039;&#039; MainUi=devcontrol - Change main user interface plugin of the Pixet program. User can programm your own plugins and one can be used instead of the Pixet main window.&lt;br /&gt;
* &#039;&#039;&#039;LogLeaveOldLogs&#039;&#039;&#039; LogLeaveOldLogs=false - Disable archiving old log files sets.&lt;br /&gt;
* &#039;&#039;&#039;LogRotateCount&#039;&#039;&#039; LogRotateCount=15 - Change number of archived log directories.&lt;br /&gt;
* &#039;&#039;&#039;HighDPI&#039;&#039;&#039; HighDPI=true - Enable AA_EnableHighDpiScaling feature in QT GUI environment. Disable can work only in very old versions of Pixet. Currently is deprecated and allways on.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Hwlibs]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of hardware library files/paths used in startup to search and connect a devices. See the hwlibs subdirectory description for details.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Examples:&#039;&#039;&#039; Left is default Pixet configuration with hwlib files in the hwlibs subdirectory, right is simple arrangement with files in the program directory. Last line is disabled in both versions.&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section example (dirs/flat structure)&#039;&#039;&#039;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|colspan=2| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Hwlibs section (old format, before 2025/09)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\widepix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
;hwlib=hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=minipix.dll&lt;br /&gt;
hwlib=widepix.dll&lt;br /&gt;
hwlib=zem.dll&lt;br /&gt;
;hwlib=zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\widepix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
;hwlibs\zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
minipix.dll&lt;br /&gt;
widepix.dll&lt;br /&gt;
zem.dll&lt;br /&gt;
;zest.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
User can disable some hwlibs using the ; symbol.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;List of HWLIB files:&#039;&#039;&#039; Windows / Linux&lt;br /&gt;
* &#039;&#039;&#039;Minipix&#039;&#039;&#039;: minipix.dll / minipix.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with Eth&#039;&#039;&#039;: zest.dll / zest.so&lt;br /&gt;
* &#039;&#039;&#039;Widepix with USB2&#039;&#039;&#039;: widepix.dll / widepix.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix&#039;&#039;&#039; or &#039;&#039;&#039;Widepix with USB3&#039;&#039;&#039;: zem.dll (and aux. file okFrontPanel.dll - allways in the program directory) / zem.so + okFrontPanel.so&lt;br /&gt;
* &#039;&#039;&#039;Advapix new&#039;&#039;&#039;: abrd-hwlib.dll / abrd-hwlib.so&lt;br /&gt;
* And customer-specific files for motor driving, x-ray sources, etc.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[Plugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths. All files is by default in the plugins subdirectory.&lt;br /&gt;
; Note&lt;br /&gt;
: Some plugins are not only for GUI Pixet&lt;br /&gt;
: Accessing specific files like as &#039;&#039;&#039;HDF5&#039;&#039;&#039;, &#039;&#039;&#039;TIFF&#039;&#039;&#039;&lt;br /&gt;
: These plugins are also needed when using an API.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;nowiki&amp;gt;[PixelmanPlugins]&amp;lt;/nowiki&amp;gt; ===&lt;br /&gt;
List of Pixet plugins files/paths with backward compatibility for old Pixelman program.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This is very obsolette. Support for Pixelman related stuff (this ini section, file formats, etc) &#039;&#039;&#039;will be removed soon&#039;&#039;&#039; without replacement.&lt;br /&gt;
&lt;br /&gt;
== Device configuration ini files ==&lt;br /&gt;
Some devices can has configuration file. Theese files are located in the program main directory or in the user data directory if the UseAppDataDir=true option used. Files have names identical to the names of the corresponding HWlibs, ending with .ini. For example, the Ethernet Widepix uses HWlib zest.dll (or zest.so on Linux) and the configuration is stored in zest.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is usually no need to edit these files, you can find details about them in the device&#039;s manual.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only for network devices it is sometimes useful to define IP addresses on which Pixet core should search for devices. Either because the general search does not work on the given network, or so that the program does not &amp;quot;steal&amp;quot; a device in another room.&lt;br /&gt;
For example, in zest.ini, each device can has its own section and an IP address defined in it:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini&amp;gt;&lt;br /&gt;
[Device0]&lt;br /&gt;
IP=10.10.1.30&lt;br /&gt;
 &lt;br /&gt;
[Device1]&lt;br /&gt;
IP=10.10.1.31&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Device firmware files ==&lt;br /&gt;
Some devices need firmware files to upload while initialization process. These files are allways located in the program directory. Names are typically composed from HWlib name and readout chip name (zemtpx3.rbf for example).&amp;lt;br&amp;gt;&lt;br /&gt;
List of this kind of files:&amp;lt;br&amp;gt;&lt;br /&gt;
zestwpx.bit, zemwpxf.rbf, zemtpx3.rbf, zemtpx3quad.rbf, zemtpx.rbf, cyptpx3pix.rbf&amp;lt;br&amp;gt;&lt;br /&gt;
Note: The standard Pixet distribution that comes with your device only contains the files for that device, so you usually won&#039;t see all of these files. And Minipix, for example, doesn&#039;t need any of it.&lt;br /&gt;
&lt;br /&gt;
== Insidious complications with files/dirs ==&lt;br /&gt;
Let&#039;s have the following program and with it pypixet.pyd and other necessary files:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir(&amp;quot;test-output&amp;quot;)&lt;br /&gt;
import pypixet&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pixet core init...&amp;quot;)&lt;br /&gt;
pypixet.start()&lt;br /&gt;
pixet=pypixet.pixet&lt;br /&gt;
devices = pixet.devices()&lt;br /&gt;
dev = devices[0]&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition (3 frames @ 1 sec) - start&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(3, 1, pixet.PX_FTYPE_AUTODETECT, &amp;quot;example.png&amp;quot;)&lt;br /&gt;
print(&amp;quot;dev.doSimpleAcquisition - end:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
pixet.exitPixet()&lt;br /&gt;
pypixet.exit()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This program normally works with e.g. Minipix, but does not work with e.q. Advapix. Crashes at pypixet.start() or has not any detected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The problem is that hwlibs load their files eg firmware from the current directory. Minipix not need any other files, Advapix need a firmware .rbf file. Moving &#039;&#039;&#039;os.chdir&#039;&#039;&#039; after &#039;&#039;&#039;pypixet.start()&#039;&#039;&#039; solves the problem.&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1718</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1718"/>
		<updated>2026-04-16T15:29:20Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or more on AdvaPIX (1.7 s with defaults).&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1717</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1717"/>
		<updated>2026-04-16T12:02:59Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or 1,7 s on AdvaPIX.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1716</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1716"/>
		<updated>2026-04-16T12:00:07Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of whole buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs or data saved to file.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or 1,7 s on AdvaPIX.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX&amp;lt;br&amp;gt;Divider can shorten the timeout downto ~500 ms. || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If an overflow occurs and the check is on, the measurement is immediately terminated with an error. If it is off, the overflow is displayed in the data and the measurement continues to the normal end. || [bool]&amp;lt;br&amp;gt;default 0 || (has no)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BlockCount&#039;&#039;&#039;&amp;lt;br&amp;gt;Count of occupied blocks after measurement.&amp;lt;br&amp;gt;(zeroed at start and updated at the end of the measurement) || (has no) || (read)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1715</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1715"/>
		<updated>2026-04-16T11:08:59Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or 1,7 s on AdvaPIX.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If overflow occurs and check is on, measurement immediately ends with error. If off, overflow indicated in data and measuring to normal end. || [bool] || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1714</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1714"/>
		<updated>2026-04-16T09:24:18Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on MiniPIX, or 1,7 s on AdvaPIX.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DataOverflowCheck&#039;&#039;&#039;&amp;lt;br&amp;gt;If overflow occurs and check is on, measurement immediatelly end with error. If off, overflow indicated in data and measuring to normal end. || [bool] || (has no)&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1713</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1713"/>
		<updated>2026-04-15T12:07:30Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1712</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1712"/>
		<updated>2026-04-14T08:22:22Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* DD functions list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must be *.t3pa, *.t3p, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1711</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1711"/>
		<updated>2026-04-13T12:14:27Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcFindNoisyPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Finds noisy pixels&lt;br /&gt;
:* Can optionally mask found pixelt in User mask (doMaskNoisyPixels)&lt;br /&gt;
:* Can optionally save mask matrix to pointed array (noisyPixelsMatrix != NULL)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double limitNoisy = 50, double limitSatur = 50, bool doMaskNoisyPixels = false, unsigned* noisyPixelsMatrix = nullptr, unsigned matrixSize = 65536&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| limitNoisy – limit [hits] to mask noisy pixels. It goes from 1 to max count value (currently only 1022), where 1 is the most strongest masking and max is the weakest.&lt;br /&gt;
| limitSatur – limit [%] to mask saturated pixels. The iToT is used, if the device has this feature. It goes from 0 to 100, where 0 is the most strongest masking and 100 is the weakest.&lt;br /&gt;
| doMaskNoisyPixels – check to mask noisy pixels within the process. Default is false alias do not mask.&lt;br /&gt;
| noisyPixelsMatrix – mask/positions of noisy pixels.&lt;br /&gt;
| matrixSize – size of the matrix.&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Currently &#039;&#039;&#039;Tpx3 only&#039;&#039;&#039;.&lt;br /&gt;
| War =  Must be run only when the device is in environment WITHOUT radiation background.&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1710</id>
		<title>File types</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1710"/>
		<updated>2026-04-09T11:12:35Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* TIFF images */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Summary =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ General image/data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII frame&#039;&#039;&#039;. Text files with img lines converted to text lines with numbers separated by spaces.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pbf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet binary frame&#039;&#039;&#039;. Simple binary files, numbers only.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pmf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet multi frame&#039;&#039;&#039;. Default is same as the txt, but multiple frames on top of each other. Can use BINARY flag.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3pa&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels ASCII&#039;&#039;&#039;. Text, CSV-like format, tab-separated columns with the header in the first row. Biggest to saving.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3p&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels&#039;&#039;&#039;. Binary format. Lower saved size than T3PA, contains simple repeats of 1 structure.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3r&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 raw&#039;&#039;&#039;. Complete data stream of Tpx3 chips. Lahge to saving, difficult to understand, slow to processing and can cause processing errors.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;png&#039;&#039;&#039; || Lossless compressed image. Easy to view, but not good for data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;tiff&#039;&#039;&#039; || &#039;&#039;&#039;TIFF, TIF&#039;&#039;&#039;, high bit-depth file usable in common graphic softwares or data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;h5&#039;&#039;&#039; || &#039;&#039;&#039;HDF5&#039;&#039;&#039;, hierarchical data format 5. Used as one of multi-frame formats.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Files auxilliary for image/data&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;dsc&#039;&#039;&#039; || Text metadata list saved beside a standard multiframe files (PMF for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;info&#039;&#039;&#039; || Text metadata list saved beside other than standard multiframe files (T3PA for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;idx&#039;&#039;&#039; || Binary index for multi-frame files. Two formats existing.&amp;lt;br&amp;gt;&lt;br /&gt;
Usesfull for fast access to n-th frame of large text files, necessary for frame seeking in binary sparse files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Special data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;clog, plog&#039;&#039;&#039; || &#039;&#039;&#039;Clusters/pixels logs&#039;&#039;&#039;. Text files contains clusters separated to frames with pixels lists. Historic formats for saving a data with few hited pixels in a frames. (&#039;&#039;&#039;obsolette&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bstg&#039;&#039;&#039; || &#039;&#039;&#039;Binary settings&#039;&#039;&#039; file. Measured or processed data with all configuration.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: BSTG files]] or see the &amp;quot;Spectraimg and data files&amp;quot; chapter in the Python API manual.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;vtxt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII vertical&#039;&#039;&#039; CSV-like file used in PIXet EDU and Clustering plugin for saving histograms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Configuration files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;xml&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ini&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
: &#039;&#039;&#039;Note&#039;&#039;&#039; Since 2025/09 release &#039;&#039;&#039;format changed&#039;&#039;&#039; to fully standard ini&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;txt&#039;&#039;&#039; ||&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;mcf&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
# DAC settings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bpc&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File type and extensions constants =&lt;br /&gt;
There are constants for file types and extensions. It can be used with [[Python API | &#039;&#039;&#039;Python API&#039;&#039;&#039;]] for filenames testing or with acquisition functions. But &#039;&#039;&#039;mostly PX_FTYPE_AUTODETECT will be enough&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Python example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Python&amp;gt;&lt;br /&gt;
# measure and save one 0.25 second frame to png file named &amp;quot;testFile.png&amp;quot;&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_PNG, &amp;quot;testFile&amp;quot;)&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_AUTODETECT, &amp;quot;testFile.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! colspan=3 | File types and extensions constants table &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! File type constants !! File extensions constants !! Ext value&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_NONE || (No direct file saving – data stored only in memory) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_AUTODETECT || (FTYPE detected by extension in a filename) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_ASCII_FRAME || PX_EXT_ASCII_FRAME || &amp;quot;txt&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_FRAME || PX_EXT_BINARY_FRAME || &amp;quot;pbf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_MULTI_FRAME || PX_EXT_MULTI_FRAME || &amp;quot;pmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_MULTIFRAME || PX_EXT_BINARY_MULTI_FRAME || &amp;quot;bmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS || PX_EXT_TPX3_PIXELS || &amp;quot;t3p&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS_ASCII ||PX_EXT_TPX3_PIXELS_ASCII || &amp;quot;t3pa&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_CLUSTER_LOG || PX_EXT_CLUSTER_LOG || &amp;quot;clog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXEL_LOG || PX_EXT_PIXEL_LOG || &amp;quot;plog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PNG || PX_EXT_PNG || &amp;quot;png&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_RAW_DATA || PX_EXT_TPX3_RAW_DATA || &amp;quot;t3r&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXET_RAW_DATA || PX_EXT_PIXET_RAW_DATA || &amp;quot;prd&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_EXTERNAL || (reserved) ||&lt;br /&gt;
|-&lt;br /&gt;
| (description file saved automatically with pmf/txt) || PX_EXT_FRAME_DESC || &amp;quot;dsc&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| (index file saved automatically with pmf/txt) || PX_EXT_INDEX || &amp;quot;idx&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File saving flags summary =&lt;br /&gt;
File saving flags can do additional settings for file(s) saving.&lt;br /&gt;
* Can be used in &#039;&#039;&#039;saving&#039;&#039;&#039; files or in &#039;&#039;&#039;doAdvancedAcquisition&#039;&#039;&#039; python methods, for example.&lt;br /&gt;
* Flags can be combined.&lt;br /&gt;
* Default frame file settings is set of separate subframes text files, with all pixels include zeros, each subframe with idx+dsc files:&lt;br /&gt;
:: file_ToT.pmf, file_ToT.pmf.dsc, file_ToT.pmf.idx, file_ToA.pmf, file_ToA.pmf.dsc, file_ToA.pmf.idx&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ File saving flags&lt;br /&gt;
|-&lt;br /&gt;
! Flag constant base name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_BINARY || Use binary format in pmf.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEX || Index + non-zero pixels in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEXY || X, Y + non-zero pixel in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NODSC || Do not add dsc file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NOSUBFRAMES || Do not use subframes, save main frame only.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_ONEFILE || Save all subframes to a single file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME || Save separate all subframes and main frame extra.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The file saving flags can be used in&lt;br /&gt;
* &#039;&#039;&#039;Python API&#039;&#039;&#039;: Use pixet.PX_FRAMESAVE_... constants in flags parameter of some measuring/saving methods.&lt;br /&gt;
* &#039;&#039;&#039;Binary API&#039;&#039;&#039;: Use PX_FRAMESAVE_... constants in flags parameter of some measuring functions.&lt;br /&gt;
* The Pixet program. Available in the &#039;&#039;&#039;More measurement settings, after compatible filename was selected&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:File-flags-dialog.png|frame|alt=File saving flags in More measurement settings in Pixet|File saving flags in More measurement settings in Pixet]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File extensions and flags: TXT/PBF/PMF details =&lt;br /&gt;
&lt;br /&gt;
== The files formats ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;width:50px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Text&#039;&#039;&#039; || Single frame in the text file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pbf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Binary&amp;amp;nbsp;Frame&#039;&#039;&#039; || Single frame in the binary file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pmf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Multi&amp;amp;nbsp;Frame&#039;&#039;&#039; || Multiframe file with text or binary format, depends on flags used with saving.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;idx&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Index&#039;&#039;&#039; || Binary array of structs with 64b pointers to start of frames, frame metadata and subframes.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;dsc&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Description&#039;&#039;&#039; || List of all metadata for each frame and subframe. Actual device and acquisition parameters, data types, etc. The &amp;quot;Frame name&amp;quot; item can be helpful to orientation in pmf structure if the ONEFILE flag used. The Type=item is helpful to understanding the structure of data if the BINARY flag used.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi-files names generation ==&lt;br /&gt;
; Note:&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; flags 0 (default), input filename = &amp;quot;name&amp;quot;, acqCount = 1&lt;br /&gt;
: name_ToA.txt, name_ToA.txt.dsc, name_ToT.txt, name_ToT.txt.dsc&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; acqCount = 6:&lt;br /&gt;
: name_0_ToA.txt, name_0_ToA.txt.dsc, name_0_ToT.txt, ...&lt;br /&gt;
: ...&lt;br /&gt;
: name_5_ToA.txt, name_5_ToA.txt.dsc, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PMF note&lt;br /&gt;
: With each pmf generating &#039;&#039;&#039;.pmf.idx&#039;&#039;&#039; binary file, other is same as TXT with acqCount = 1.&lt;br /&gt;
&lt;br /&gt;
== Files with flags=0 ==&lt;br /&gt;
; Note&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; TXT file data, default&lt;br /&gt;
: 0 0 0 5 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0 872 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: (256 lines)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PBF file data, default&lt;br /&gt;
: Simple pixels binary data without anything else&lt;br /&gt;
: Data can be typically 16 or 32 bit raw integers with little-endian order and doubles for calibrated data.&lt;br /&gt;
: For example, MiniPIX has single chip, this has 65536 pixels, it&#039;s binary file has 65536 words (size 128 kB binary), sometimes 65536 doubles (size 512 kB binary).&lt;br /&gt;
: The &#039;&#039;&#039;data format&#039;&#039;&#039; can be read in the line starting with Type= line in the [[#DSC files details | &#039;&#039;&#039;DSC file&#039;&#039;&#039;]] saved beside the data file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PMF file data, default&lt;br /&gt;
: 0.00000 78.65742 0.00000 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0.00000 0.00000 999785.5 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter &lt;br /&gt;
: (256 lines * acqCount)&lt;br /&gt;
&lt;br /&gt;
== Flags influence to files ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEX flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| _ToA.txt file !!colspan=&amp;quot;2&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 227212.500000 || 0 || 20&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 310685.937500 || 17 || 13&lt;br /&gt;
|-&lt;br /&gt;
| 255 || 265487.500000 || 255 || 11&lt;br /&gt;
|-&lt;br /&gt;
| 1274 || 105728.125000 || 1274 || 9&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;4&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEXY flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;3&amp;quot;| _ToA.txt file !!colspan=&amp;quot;3&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 247 || 3 || 189851.562500 || 247 || 3 || 16&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 4 || 140042.187500 || 250 || 4 || 12&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 9 || 317195.312500 || 5 || 9 || 5&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;6&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;6&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;PMF file data, pixet.PX_FRAMESAVE_SPARSEX(Y) flag&#039;&#039;&#039;&amp;lt;br&amp;gt;Same as TXT, but containing single lines with only # to separate frames&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! X !! Y !! ToA !! Line description&lt;br /&gt;
|-&lt;br /&gt;
| 232 || 139 || 321620.312500 || frame 1, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 252 || 340231.250000 || frame 1, px 2&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;3&amp;quot;| # || frames separator&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 0 || 258270.312500 || frame 2, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 201 || 0 || 76593.750000 || frame 2, px 2&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 1 || 268642.187500 || frame 2, px 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_ONEFILE&lt;br /&gt;
: All the data is in one file, subframes are placed one behind the other. If the measurement result has 10 frames with 2 subframes A/B, each _n TXT file contains 2 subrfames and the PMF contains 20 frames in order:&lt;br /&gt;
: sfr0A, sfr0B, sfr1A, sfr1B, ...&lt;br /&gt;
: The exact order and names of type of (sub)frames is listed in the DSC file. The DSC have separate records [Fn] for all the items.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME&lt;br /&gt;
: The group of the saved files contains the main frame and all subframes. Subframe files end in _sfrName, the main frame does not. In DSC file accompanying the TXT with main frame is not the &amp;quot;Frame name&amp;quot; item.&lt;br /&gt;
: Not applicable if combined with the &#039;&#039;&#039;ONEFILE&#039;&#039;&#039; flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_BINARY&lt;br /&gt;
: If the file type supports text and binary format, ex. PMF, save the binary.&lt;br /&gt;
: Not applicable to TXT, must use PBF instead.&lt;br /&gt;
: Data in the file are the simple array of non-calibrated 16 or 32b integers or calibrated doubles. See the DSC file for used data type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BINARY + SPARSEXY examples:&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
[[File:File-binary-sparsexy-example.png|frame|none|alt=Example of data saved if flags BINARY+SPARSEXY used|Example of data saved if flags BINARY+SPARSEXY used]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Timepix3 specific data files =&lt;br /&gt;
The Timepix3 have the data-driven mode feature. It is &amp;quot;frameless&amp;quot; mode, where the device can continuously send the data of the pixels just hit indefinitely. Each sent pixel contains information:&lt;br /&gt;
# Pixel position index&lt;br /&gt;
# Event registration time (raw ToA count and FToA, conversion and corrections needed)&lt;br /&gt;
# Energy deposited in a pixel (raw ToT count, need conversion using the chip-specific calibration table containing cal. constants for each pixel)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Theese files can be very large. You can collecting a data from cosmic particles using Minipix continuously for more weeks and get a T3PA sized in tens of megabytes. But if some noising pixel occurs, a files can has many gygabytes per day. If the Advapix used with x-ray mashines or accelerators, the output data can has gigabytes in an instant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The formats:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;T3PA&#039;&#039;&#039; files are &#039;&#039;&#039;text/csv&#039;&#039;&#039; files with basic data. User can simply see it in text editor and process it in Python etc.&lt;br /&gt;
* &#039;&#039;&#039;T3P&#039;&#039;&#039; files are &#039;&#039;&#039;binary&#039;&#039;&#039; files with basic data same as T3PA. Faster saving, shorter files.&lt;br /&gt;
* &#039;&#039;&#039;T3R&#039;&#039;&#039; files are binary files with complete raw communication data. &#039;&#039;&#039;For special purposes only.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data order&#039;&#039;&#039;&lt;br /&gt;
* The order of the data roughly corresponds to the order of events, so data an hour later will definitely be further in the file.&lt;br /&gt;
* But the exact order corresponds to the order in which the data came from the device, so for example a later event that occurred at the edge where the chip is read can be recorded earlier than an earlier event that occurred further from the edge.&lt;br /&gt;
* The unevenness of the order occurs from tens of ns on a lightly loaded Advapix to several ms with a heavy load on the Minipix.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;How to get the files:&#039;&#039;&#039;&lt;br /&gt;
* In the [[PIXet|&#039;&#039;&#039;Pixet&#039;&#039;&#039;]] program set operation mode to ToA+ToT and use the &amp;quot;Pixels&amp;quot; measurement type and turn on file saving.&lt;br /&gt;
* In the [[Binary_core_API|&#039;&#039;&#039;binary API&#039;&#039;&#039;]] using programs set operation mode to PXC_TPX3_OPM_TOATOT and use the [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]] function.&lt;br /&gt;
* In the [[Python API|&#039;&#039;&#039;Python API&#039;&#039;&#039;]] using programs set operation mode to pixet.PX_TPX3_OPM_TOATOT and use the dev.&#039;&#039;&#039;doAdvancedAcqquisition&#039;&#039;&#039; with acqType=pixet.PX_ACQTYPE_DATADRIVEN.&lt;br /&gt;
&lt;br /&gt;
== T3PA files details ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 pixels ASCII file&#039;&#039;&#039; is timepix3 data file in text format with lines and tabs. Can be read as CSV, but its size is not limited to sizes readable by Office-like programs . Contains the header line and data lines with record index, pixel index in the matrix, Time of arrival, Time over threshold, Fine ToA and Overflow.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The T3PA example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Index   Matrix Index    ToA     ToT     FToA    Overflow&lt;br /&gt;
0       1028    1918    14      22      0&lt;br /&gt;
1       1028    3126    8       28      0&lt;br /&gt;
2       1028    3778    5       23      0&lt;br /&gt;
...&lt;br /&gt;
156003  39793   98473646054     38      9       0&lt;br /&gt;
156004  190     98492090610     19      3       0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Index&#039;&#039;&#039; is simple index of measurement line. This growing while measurement is running. If you append new measurement to existing file, new index is 0 again and again growing while new measurement is running.&lt;br /&gt;
[[File:Minipix-pixel00.png|frame|right|alt=Physical position of the x=0, y=0 pixel on the Minipix|Physical position of the x=0, y=0 pixel on the Minipix]]&lt;br /&gt;
* The &#039;&#039;&#039;Matrix Index&#039;&#039;&#039; is index of the pixel. On the Minipix Tpx3 is 0 at the left-down (see image)&lt;br /&gt;
* The &#039;&#039;&#039;ToA&#039;&#039;&#039; is time of arrival in units 25 ns, mod by limit specific by device type.&lt;br /&gt;
:: For example Minipix 2&amp;lt;sup&amp;gt;64&amp;lt;/sup&amp;gt; (14600y), Advapix-single 2&amp;lt;sup&amp;gt;30&amp;lt;/sup&amp;gt; (26s), Advapix-Quad 2&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (6.5s).&lt;br /&gt;
: &#039;&#039;&#039;Note:&#039;&#039;&#039; The ToA on-chip implementation in the pixels is limited to 14 bits (409.6 µs).&lt;br /&gt;
:: The ToA in T3PA is extended by device. But there is inherent uncertainty around the borders. These values may be incorrectly assigned. Users not comfortable with our extension can apply AND with (uint64)16383 to extended ToA to get original ToA from the chip.&lt;br /&gt;
* The &#039;&#039;&#039;ToT&#039;&#039;&#039; is time over threshold in units 25 ns.&lt;br /&gt;
* The &#039;&#039;&#039;FToA&#039;&#039;&#039; stands for &amp;quot;fine ToA&amp;quot; and it is the finest step of the ToA measurement. To properly account for this step in the conversion of ToA to time, it is necessary to subtract the amount of counts of fToA in the following manner:&lt;br /&gt;
:: &#039;&#039;&#039;Time [ns] = 25*ToA - (25/16)*fToA&#039;&#039;&#039;&lt;br /&gt;
: The original range of this fToA value in the chip is 4 bits, or 16 values. This is extended in the post-processing of the data into 5 bits, or 32 values to include a correction for Intentional phase shift of clocks propagated into the columns of the chip. The final value exported into t3pa files has a range of 5 bits, or 32 values, but the previous equation still stands.&lt;br /&gt;
* The &#039;&#039;&#039;Overflow&#039;&#039;&#039; is sign of data transfer overflow or other special cases.&lt;br /&gt;
:: &#039;&#039;&#039;Note:&#039;&#039;&#039; In data from multichip devices, there is not Overflow, replaced by Chip index (=copy of bits 16+ of Matrix Index. But column name is still Overflow).&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;1 - data transfer overflow&#039;&#039;&#039;:&lt;br /&gt;
::: matrix index = 0x74: start of lost data&lt;br /&gt;
::: matrix index = 0x75: end of lost data, toa is length of the missing time&lt;br /&gt;
::: (this can occurs with rates over megahits per seconds for Minipix)&lt;br /&gt;
::: matrix index = 0: Data corruption event detected - all next data can be corrupted&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;10 - trigger timestamp&#039;&#039;&#039; (If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled):&lt;br /&gt;
::: matrix index = 0, ToT = 0&lt;br /&gt;
::: ToA = Timestamp of arrival external sync pulse to the device.&lt;br /&gt;
::: FToA = Count of expected ToA counter overflows.&lt;br /&gt;
::: If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, every sync pulse cause creating of one line record, independent of sync is or is not used to start of the acquisition. Timestamps can be recorded some time before the measurement starts. They may have zero or, conversely, an arbitrarily high value.&lt;br /&gt;
::: Warnings:&lt;br /&gt;
:::* Be careful about having too high values ​​in the FToA column (increment every 409.6 µs).&lt;br /&gt;
:::* Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&lt;br /&gt;
&lt;br /&gt;
* Related: [[The_RawTpx3Pixel_structure_in_memory#Explanation_of_the_struct|The RawTpx3Pixel structure in memory: Explanation of the struct]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If &#039;&#039;&#039;saving of the T3PA repeated to the same file&#039;&#039;&#039;, new data will be append with new reset of record index and ToA and the file containing parts is like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
507812	353	39993345	1022	15	0&lt;br /&gt;
507813	46177	39999843	159	2	0&lt;br /&gt;
507814	45921	39999843	159	2	0&lt;br /&gt;
0	421	2	13	29	0&lt;br /&gt;
1	297	2	22	27	0&lt;br /&gt;
2	297	145	62	17	0&lt;br /&gt;
3	297	283	19	13	0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3P files details ==&lt;br /&gt;
&#039;&#039;&#039;Timepix3 Binary Pixels&#039;&#039;&#039; is similar to t3pa file without record index. And the numbers are not saved as ASCII, but binary. The file contains one pixel after each other. Each pixel in this format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 matrixIdx;&lt;br /&gt;
u64 toa;&lt;br /&gt;
byte overflow;&lt;br /&gt;
byte ftoa;&lt;br /&gt;
u16 tot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P file contents example:&#039;&#039;&#039;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ As see in a HEX editor&lt;br /&gt;
|- &lt;br /&gt;
| 5E86 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0300&lt;br /&gt;
|-&lt;br /&gt;
| 6087 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 6387 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 001B || 0100&lt;br /&gt;
|-&lt;br /&gt;
| 6486 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 5D84 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0010 || 0200&lt;br /&gt;
|-&lt;br /&gt;
| 89BD || 0000 || 240B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0D00&lt;br /&gt;
|-&lt;br /&gt;
| 5F80 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0002 || 0600&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ Redistributed according the structure&lt;br /&gt;
|-&lt;br /&gt;
! pxIdx&amp;lt;br&amp;gt;4 B !! ToA&amp;lt;br&amp;gt;8 B !! Over&amp;lt;br&amp;gt;1 B !! fToA&amp;lt;br&amp;gt;1 B !! ToT&amp;lt;br&amp;gt;2 B&lt;br /&gt;
|-&lt;br /&gt;
| 5E 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 03 00&lt;br /&gt;
|-&lt;br /&gt;
| 60 87 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 63 87 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 1B || 01 00&lt;br /&gt;
|-&lt;br /&gt;
| 64 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 15 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 5D 84 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 10 || 02 00&lt;br /&gt;
|-&lt;br /&gt;
| 89 BD 00 00 || 24 0B 00 00 00 00 00 00 || 00 || 15 || 0D 00&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Corresponding start of T3PA&lt;br /&gt;
: Index &amp;amp;nbsp;	Matrix Index &amp;amp;nbsp;	ToA &amp;amp;nbsp;	ToT &amp;amp;nbsp;	FToA &amp;amp;nbsp;	Overflow&lt;br /&gt;
: 0  &amp;amp;nbsp; 34398  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 3  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 1  &amp;amp;nbsp; 34656  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 2  &amp;amp;nbsp; 34659  &amp;amp;nbsp; 2847   &amp;amp;nbsp; 1  &amp;amp;nbsp; 27 &amp;amp;nbsp; 0&lt;br /&gt;
: 3  &amp;amp;nbsp; 34404  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 21 &amp;amp;nbsp; 0&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;Overflow value&#039;&#039;&#039; - Data transfer overflow indicator or other special value indicator.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#T3PA files details]] for details and see below for T3P differences in the trgTimeStamp.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P files with trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Note: This is old internal testing feature and was not intended for mormal using. If you do want to use it, here&#039;s some info:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, file can contains lines of tab-divided ASCII numbers. Every record is six numbers divided by tabs (0x09) and ended with line end (0x0A).This is simple T3PA line. See the T3PA with overflow=10 for details.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every sync pulse cause creating of one line record. In the file, each sync record and each pixel are simply stored in the order as it arrived on the computer. Any combination of order and number of binary and text records can be expected.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This is a source of complications when using the file. The file must be browsed sequentially as binary pixels. At the first occurrence of faulty or suspicious values (eg high pixel index, high ToA, Overflow&amp;gt;1) assume that the current record is not a pixel, but that the ASCII/tab line starts here and that it ends at 0A.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3R files ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 Raw Data File&#039;&#039;&#039; is special format for testing purposes. This is a dump of raw communication from the device. The file format is device specific, binary, complex and files are very large. Use this only if you have no other option.&lt;br /&gt;
&lt;br /&gt;
= DSC/INFO metadata files =&lt;br /&gt;
The metadata text files are saved beside the data files and containing informations about device and settings used for measuring the data. It can be usable while openning the data file in the Pixet program or in other working with the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the API is used to saving the data, programmer can use callback like us &amp;quot;&#039;&#039;&#039;before saving data callback&#039;&#039;&#039;&amp;quot; to add Your specific metadata items or can remove items that will not need.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;DSC&#039;&#039;&#039; are files generated beside the frame data and cotaining information for each frame&lt;br /&gt;
* &#039;&#039;&#039;INFO&#039;&#039;&#039; are files generated beside pixel data and some special data formats&lt;br /&gt;
&lt;br /&gt;
== DSC files details ==&lt;br /&gt;
The first line is &#039;&#039;&#039;header line&#039;&#039;&#039;:&lt;br /&gt;
: Some like as &#039;&#039;&#039;A123456789&#039;&#039;&#039;: B=binary / A=ASCII and number = count of frames in multiframe data file&lt;br /&gt;
Next are &#039;&#039;&#039;frames&#039;&#039;&#039; in format:&lt;br /&gt;
: &#039;&#039;&#039;1. [Fn]&#039;&#039;&#039; - Frame with idx n start: [F0], [F1], ...&lt;br /&gt;
: &#039;&#039;&#039;2. Frame type&#039;&#039;&#039; - Data type, pixel format and frame size: Some like as &amp;quot;Type=i16 [X,C] width=256 height=256&amp;quot;&lt;br /&gt;
:: Pixels format options:&lt;br /&gt;
::: &#039;&#039;&#039;matrix&#039;&#039;&#039; - Whole matrix saved. Number of saved pixels are allways width*height.&lt;br /&gt;
:::: Multiframe data file not contains frame separator.&lt;br /&gt;
::: &#039;&#039;&#039;[X,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has matrix index and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
::: &#039;&#039;&#039;[X,Y,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has X,Y position and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
: &#039;&#039;&#039;3. Frame metadata&#039;&#039;&#039; - List of metadata items separated by blank lines:&lt;br /&gt;
::: Each metadata item is line triplet:&lt;br /&gt;
:# &amp;quot;Item name&amp;quot; (&amp;quot;Item description&amp;quot;): Example: &amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
:# DataType[valCount] Example: double[1]&lt;br /&gt;
:# Values list Example: 0.500000&lt;br /&gt;
:# (blank line)&lt;br /&gt;
: &#039;&#039;&#039;4. (blank line)&#039;&#039;&#039; - end of frame (there are two blank lines, the last metadata item end and the frame end)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In &#039;&#039;&#039;txt.dsc&#039;&#039;&#039; and &#039;&#039;&#039;pbf.dsc&#039;&#039;&#039;, end of the frame is end of the file.&amp;lt;br&amp;gt;&lt;br /&gt;
In the &#039;&#039;&#039;pmf.dsc&#039;&#039;&#039;, next frames or subframes metadata follows.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Some example (PBF 1 frame, with BINARY and SPARSEXY – test_49_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001                                      B=binary / A=ASCII and number = count of frames in multiframe file&lt;br /&gt;
[F0]                                            Index of frame in the file = 0&lt;br /&gt;
Type=double [X,Y,C] width=256 height=256        Data type double, X,Y,C = only hit pixels saved and has XY pos.&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):  Some metadata item name and (description)&lt;br /&gt;
u32[1]                                          Type of the item data [number of values]&lt;br /&gt;
49                                              The value&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA                                             This is the ToA frame&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
(end of the file)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Other example (PMF 10 frames, with BINARY+SPARSEX+ONEFILE – test.pmf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000010&lt;br /&gt;
[F0]                                            Start of the first subframe&lt;br /&gt;
Type=double [X,C] width=256 height=256          Pixel index and double type pixel data (ToA in ns)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA &lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[F1]                                            Start of the second subframe&lt;br /&gt;
Type=i16 [X,C] width=256 height=256             Pixel index and i16 type pixel data (ToT in ticks 40MHz)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
(and the ToT frame metadata, [F2] and ToA subframe, [F3] and ToT sfr, … [Fn] and ToT sfr of (n/2)th frame)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Complete one frame DSC example (PMF 1 frame, BINARY+SPARSEX – test_15_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001&lt;br /&gt;
[F0]&lt;br /&gt;
Type=double [X,C] width=256 height=256&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
15&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059034.903085 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
0.500000&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
I08-W0060&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1301 501 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-500 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.7.8&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059042.934810 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Thu Dec 9 15:10:42.934809 2021&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.026744&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== INFO files details ==&lt;br /&gt;
* The T3PA.INFO containing metadata in format very similar to one frame of DSC file.&lt;br /&gt;
* Some other INFO files can containing simpliest formated metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;T3PA.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[FileInfo]&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.719000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1.000000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
D06-W0065&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1237 437 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-450 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.8.1&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Shutter open time&amp;quot; (&amp;quot;Shutter open timestamp&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Tue Jan  9 15:12:18.867000 2024&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.015797 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;BMF.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[File Meta Data]&lt;br /&gt;
Acq Serie Index:0&lt;br /&gt;
Acq Serie Start time:1704813831.469&lt;br /&gt;
Acq time:0.001&lt;br /&gt;
ChipboardID:G03-W0259&lt;br /&gt;
DACs:10 100 255 127 127 0 153 6 130 100 80 85 128 128&lt;br /&gt;
HV:-450&lt;br /&gt;
Interface:AdvaPIX&lt;br /&gt;
Mpx type:2&lt;br /&gt;
Pixet version:1.8.1&lt;br /&gt;
Start time:1704813831.633&lt;br /&gt;
Start time (string):Tue Jan  9 16:23:51.633000 2024&lt;br /&gt;
Threshold:5.02649397407217&lt;br /&gt;
Timepix clock:50&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= IDX files details =&lt;br /&gt;
The IDX files are generated with multiframe files to help with fast seeking frames in files. &#039;&#039;&#039;Each frame except first&#039;&#039;&#039; has the basic structure in the IDX file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct IndexItem {&lt;br /&gt;
 i64 dscPos;    // frame position in the DSC file&lt;br /&gt;
 i64 dataPos;   // frame position in the main data file&lt;br /&gt;
 i64 sfPos;     // subframe position if exist subframes file next to the main data file (usually not and =0)&lt;br /&gt;
};&lt;br /&gt;
// Note: CLOG.IDX has no this structure, this in only i64 pointers to frames&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;PMF.IDX&#039;&#039;&#039; files generated beside the PMFs. Contains the simple binary array of structs of 3 little-endian qwords with addresses associated to the start of each frame except first: DSC, frame and subframe.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
; .pmf.idx with BINARY+ONEFILE, ToA+ToT example&lt;br /&gt;
: main data contains&lt;br /&gt;
:* ToA subframes (double*0x10000 = len 0x80000)&lt;br /&gt;
:* ToT subframes (i16*0x10000 = len 0x20000)&lt;br /&gt;
The IDX contains&lt;br /&gt;
# Pointers to frames in DSC file at 0 (not in idx), 0x03B5, 0x075D, 0x0B08, 0x0BE0, ... (points to an empty line before [Fx] line)&lt;br /&gt;
# Pointers to frames in main data file at 0 (not in idx), 0x080000, 0x0A0000, 0x120000, 0x140000, 0x1C0000, ...&lt;br /&gt;
# Pointers to frames in additional subframes file (not exist -&amp;gt; all=0)&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-pmf-idx-example.png|frame|right|alt=.pmf.idx file example|.pmf.idx file example]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= HDF5 files =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The HDF5 (&#039;&#039;&#039;.H5&#039;&#039;&#039;) files are general standard binary containers for structured data. If used to save, contains both measured data and metadata.&lt;br /&gt;
* To access theese files, use third party tools like as:&lt;br /&gt;
:* &#039;&#039;&#039;HDFview&#039;&#039;&#039; from HDF Group&lt;br /&gt;
:* &#039;&#039;&#039;h5py&#039;&#039;&#039; python library from HDF Group&lt;br /&gt;
:: See: [[Python_API#Examples|&#039;&#039;&#039;Python API: Examples&#039;&#039;&#039;]] for reading using Python&lt;br /&gt;
:* &#039;&#039;&#039;HDF5 C++ API&#039;&#039;&#039; from HDF Group&lt;br /&gt;
* If you are saving from the API without Pixet, the &#039;&#039;&#039;hdf5io.dll&#039;&#039;&#039; plugin must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the hdf5io plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:left; vertical-align:top;&amp;quot;| The plugin file must exist in the directory:&lt;br /&gt;
| [[File:Plugin-hdf5.png|thumb|alt=HDF5 plugin file in plugins directory|HDF5 plugin file in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Saving a HDF5 files ==&lt;br /&gt;
* The files can be saved from the Pixet program or by API.&lt;br /&gt;
: [[File:Files-hdf5-saving-pixet.png|frame|none|alt=Saving HDF5 from the Pixet program|Saving HDF5 from the Pixet program:&amp;lt;br&amp;gt;First was saved the &#039;&#039;&#039;test.h5&#039;&#039;&#039;, second the &#039;&#039;&#039;test.h5:meas2&#039;&#039;&#039;]]&lt;br /&gt;
* When saving to an existing file, the data is added to the existing structure in it.&lt;br /&gt;
* Use the AUTODETECT filetype in the API functions using filetype.&lt;br /&gt;
* Saving flags will be ignored.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Next image showing 3 files in the HDFview program&lt;br /&gt;
# File test1.h5 saved by acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
# File test2.h5 saved by tripple acquisitions of 10 frames, with filename settings &amp;quot;test1.h5:set0&amp;quot;,  &amp;quot;test1.h5:set1&amp;quot; and  &amp;quot;test1.h5:set2&amp;quot;.&lt;br /&gt;
# File test1.h5, existing from first acq., saved again in next acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-hdf5-examples.png|frame|none|alt=HDF5 files examples in HDFview|HDF5 files examples in HDFview: Single acq. with 10 frames, triple with structure, first file after second acq.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The files was saved from the PY script:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=Python start=60&amp;gt;&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set0&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set1&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set2&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pixet structures in HDF5 ==&lt;br /&gt;
As see at the &amp;quot;HDF5 files examples&amp;quot; image in the previous chapter, the acquisition creates the file with structure (or adds to existing):&lt;br /&gt;
# Root name or path if defined by adding :hdfpath at end of filename (optional)&lt;br /&gt;
# Frame list: Frame_0, Frame_1, ...&lt;br /&gt;
# Main frame data: The Data item&lt;br /&gt;
# Basic informations items: AcqTime, Width, Height, StartTime&lt;br /&gt;
# MetaData directory containing same data as saved to the dsc files alongise classic simple data files.&lt;br /&gt;
# SubFrames directory with subframes subdirs named by subframe names (ToA, ToT, Event, iToT, ...) containing same structures as the main frame.&lt;br /&gt;
&lt;br /&gt;
= TIFF images =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The TIFF (&#039;&#039;&#039;.TIFF / .TIF&#039;&#039;&#039;) &amp;quot;Tag Image File Format&amp;quot;, files are image format for high-resolution and high-bitDepth data and has multi-page support. If used to save, contains measured data in 32 bit integer format.&lt;br /&gt;
* If saving from API without the Pixet program, the &#039;&#039;&#039;tiffio.dll plugin&#039;&#039;&#039; must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]* Note: Multipage format is not yet supported in Pixet. &lt;br /&gt;
* To simplify further data processing, Pixet saving an integer data only in 32bit format without any conversion. Or if data is double/float, the conversion factor is used (change it in the File output tab on Measurement settings dialog).&lt;br /&gt;
* To facilitate processing, an &#039;&#039;&#039;auxiliary file .tiff.aux.xml&#039;&#039;&#039; is also saved with the image. Note: Contents are completelly different from DSC/INFO files.&lt;br /&gt;
* It very often happens that integer data has negligible values ​​against the range of 32 bits (over 4 billion). This can cause the image &#039;&#039;&#039;looks like completely black&#039;&#039;&#039; when viewed in some programs, even though it contains data.&lt;br /&gt;
* The image can be shown in the Pixet. Drag-drop the image to the image zone. Recommended view settings: Auto range / Smart&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the tiffio plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:left; vertical-align:top;&amp;quot;| The plugin file must exist in the directory:&lt;br /&gt;
| [[File:Plugin-tiff.png|thumb|alt=TIFF plugin files in plugins directory|TIFF plugin files in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Configuration files =&lt;br /&gt;
Ecosystem of the Pixet software containing many configuration files and formats. Part of this was inherited from the old Pixelman program. Do not use formats marked OBSOLETE to save new data. Load old data and save it to new formats before support ends.&lt;br /&gt;
&lt;br /&gt;
== Calibration files ==&lt;br /&gt;
# Threshold DAC/energy curves of every pixel are different. For proper device function the threshold adjustment matrix needed. This data is part of the pixel matrix configuration and it is part of the device XML config file.&lt;br /&gt;
# If the readout chip supports energy measuremnts, You need calibration data for convert digital data to the energy in keVs. Every pixel has own calibration coeficients. It&#039;s values depends on sensor chip local differences.&lt;br /&gt;
::* Calibration in the device config file - simpliest variant. The device config file contains calibration section with encoded binary data.&lt;br /&gt;
::* Set of the calibration files - files named name_a.txt, name_b.txt, name_c.txt and name_t.txt. Data is in the text matrix like in the frame files.&lt;br /&gt;
::* Most functions support using filename &amp;quot;name.xml&amp;quot; or &amp;quot;name_a.txt|name_b.txt|name_c.txt|name_t.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix configuration files ==&lt;br /&gt;
Contains matrix of:&lt;br /&gt;
# threshold adjustment bits of the pixel&lt;br /&gt;
# if the pixel is masked&lt;br /&gt;
# if test is on&lt;br /&gt;
# other bits depending on the chip type&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Overview&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;nbsp;&#039;&#039;&#039;bpc&#039;&#039;&#039;&amp;amp;nbsp;&lt;br /&gt;
|| &#039;&#039;&#039;Binary Pixel Configuration&#039;&#039;&#039; || All PM config in one file, meaning of the bits depends on the chip.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Mask Matrix&#039;&#039;&#039; || Text file with pixel mask&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Test Bit Matrix&#039;&#039;&#039; || Text file with test bits&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii THL adj. bits Matrix&#039;&#039;&#039; || Text file with threshold values adjustment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== XML format ==&lt;br /&gt;
Standard XML files&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== INI format ==&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: The original implementation in Pixet environment &#039;&#039;&#039;was non-standard&#039;&#039;&#039;. Older files have sections, such as [hwlibs], which contain values ​​themselves without name= beginnings.&lt;br /&gt;
: Starting &#039;&#039;&#039;from 2025/09 we are switching to standard INI&#039;&#039;&#039;. In sections where previously item beginnings were missing, we have switched to named items, where the name does not matter.&lt;br /&gt;
&lt;br /&gt;
== TXT format ==&lt;br /&gt;
All except DAC settings is simple matrix with lines containing numbers separated by spaces.&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Obsolete files =&lt;br /&gt;
All formats in this chapter are obsolete and, with the exception of CLOG, has not used for long time and it is possible that their support will be removed.&lt;br /&gt;
Pay attention to possible ambiguities when using CLOG.&lt;br /&gt;
&lt;br /&gt;
== CLOG and PLOG files ==&lt;br /&gt;
Old text formats from age of the first Timepix chips. Due to the new use with Tpx3, new ambiguities in CLOG have arisen.&lt;br /&gt;
* &#039;&#039;&#039;CLOG&#039;&#039;&#039; (clusters log) has remained popular in the context of cluster processing.&lt;br /&gt;
* &#039;&#039;&#039;PLOG&#039;&#039;&#039; (pixels log) is currently no longer used.&lt;br /&gt;
&lt;br /&gt;
=== CLOG and CLOG.IDX files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
The CLOG format was developed to facilitate further processing of cluster data by the user programs. This is a text file divided to the frame records and the records can contain a clusters. Frames and clusters are separated by the line breaks. Frames can be separated by whole free line.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The record format&lt;br /&gt;
: Frame FN (frameStart, frameAcqTime s)&lt;br /&gt;
: [x, y, energy, ToA] [x, y, energy, ToA] [x, y, energy, ToA] ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;FN&#039;&#039;&#039; || Frame index number. First 0 or 1.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameStart&#039;&#039;&#039; || Start time of the frame. There are variants:&lt;br /&gt;
1. If it from measuring or from replay frame-based data with metadata available:&lt;br /&gt;
: Linux format, frame starting time from PC’s getPrecisionTime.&lt;br /&gt;
2. If it from pixel-based data with metadata available (file.t3pa + file.t3pa.info):&lt;br /&gt;
: Linux format, acq. starting time from PC’s getPrecisionTime with added time from data.&lt;br /&gt;
3. If it from replay data and metadata not available:&lt;br /&gt;
: Nanoseconds from the input data.&lt;br /&gt;
: Periodic increments if source is frame-based, random increments if source is data-driven.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameAcqTime&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; || Duration of the frame, float in seconds. Always 0.000000 in data from data-driven sources.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;x, y&#039;&#039;&#039; || Position of the pixel.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;energy&#039;&#039;&#039;* || Energy deposited in the pixel. Integer ToT counter value if not calibrated, float in keV if calibrated.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;ToA&#039;&#039;&#039;* || Time of arrival, relative to frameStart. Integer in CLK ticks if ToA conversion is disabled, float in ns if ToA conversion is enabled.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;*&#039;&#039;&#039;ToA+energy records can be created from source that supports combined ToA+ToT modes, like as OPM_TOATOT on the Timepix3. If the data source supports only single modes, only one value is in this position.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;data-driven&#039;&#039;&#039; source &#039;&#039;&#039;not&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;frame-based&#039;&#039;&#039; source &#039;&#039;&#039;can&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix3, Frame2 with two clusters by 2 and 4 pixels, Frame3 with single 2-pixel cluster)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 2 (273697060.937500, 0.000000 s)&lt;br /&gt;
[214, 195, 43.1598, 0] [220, 191, 20.6515, 7.8125]&lt;br /&gt;
[224, 182, 21.8018, 31.25] [223, 186, 4.58576, 31.25] [222, 183, 38.2381, 31.25] [226, 185, 14.7623, 34.375]&lt;br /&gt;
&lt;br /&gt;
Frame 3 (371034565.625000, 0.000000 s)&lt;br /&gt;
[151, 33, 32.5745, 0] [151, 34, 13.8135, 17.1875]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 6 (1639143482.765164, 0.200000 s)&lt;br /&gt;
[87, 134, 5.75352] [217, 58, 14.8396]&lt;br /&gt;
Frame 7 (1639143483.019154, 0.200000 s)&lt;br /&gt;
Frame 8 (1639143483.261158, 0.200000 s)&lt;br /&gt;
Frame 9 (1639143483.513150, 0.200000 s)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| The &#039;&#039;&#039;CLOG.IDX&#039;&#039;&#039; files generated beside the CLOGs. Contains the simple binary array of little-endian qword addresses of the &amp;quot;F&amp;quot; at each record start.&amp;lt;br&amp;gt;&lt;br /&gt;
; .clog.idx example&lt;br /&gt;
: Pointers to records at 0, 0x29, 0x52, 0x7b, 0xA4, 0xCD, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The &#039;&#039;&#039;CLOG.IDX is different&#039;&#039;&#039; from ordinary ones [[#IDX files details|IDX files]].&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-clog-idx-example.png|frame|alt=Example .clog.idx file|Example .clog.idx file]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== PLOG files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Like as CLOG&#039;&#039;&#039;, but with simple lists of hit pixels of a frames.&lt;br /&gt;
* &#039;&#039;&#039;Metatdata section&#039;&#039;&#039; at start.&lt;br /&gt;
* &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format usable only with &#039;&#039;&#039;Timepix&#039;&#039;&#039; (first generation) chips.&lt;br /&gt;
:: Saved data are main frame only.&lt;br /&gt;
:: IDX is like CLOG.IDX, but items points to [ at start of each frame.&lt;br /&gt;
:: Recommended to use PMF with SPARSEX(Y) flag instead it.&lt;br /&gt;
&lt;br /&gt;
== Advapix specific data files ==&lt;br /&gt;
New data formats were created for early AdvaPIX variants based on special requirements, but their use was minimal. This chapter serves mainly in case you have such data from the past and need to process it with your software.&lt;br /&gt;
&lt;br /&gt;
=== BMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
This special file contains a &#039;&#039;&#039;binary matrix data from fast measurements&#039;&#039;&#039; (AdvaPIX-Tpx and ModuPIX devices).&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format for obsolete devices&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! BMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
To save theese files the Advapix-Timepix must be used, set the fast mode by setting acq. time 0.01 sec or shorter and frames count divisible by 100.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The file starts with 13 bytes long header and then is followed by pixel values of each frame. Each frame has a few dummy bytes at the beginning. So the layout of the file is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[HEADER][Frame 1][Frame 2][Frame 3] ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where header is 13 bytes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 width;&lt;br /&gt;
u32 height;&lt;br /&gt;
u32 offset;&lt;br /&gt;
char frameType;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;witdh&#039;&#039;&#039; and &#039;&#039;&#039;height&#039;&#039;&#039; is the dimensions of each frame.&lt;br /&gt;
* Each frame data is prepended by &#039;&#039;&#039;offset&#039;&#039;&#039; number of dummy bytes.&lt;br /&gt;
* The &#039;&#039;&#039;frameType&#039;&#039;&#039; specifies the type (variable type) of pixel values. It can be one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
CHAR = 0 (1 byte size)&lt;br /&gt;
BYTE = 1 (1 byte size) &lt;br /&gt;
I16 = 2 (2 bytes size)&lt;br /&gt;
U16 = 3 (2 bytes size)&lt;br /&gt;
I32 = 4 (4 bytes size) &lt;br /&gt;
U32 = 5 (4 bytes size)&lt;br /&gt;
I64 = 6 (8 bytes size)&lt;br /&gt;
U64 = 7 (8 bytes size)&lt;br /&gt;
FLOAT = 8 (4 bytes size)&lt;br /&gt;
DOUBLE = 9 (8 bytes size)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== AMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039;, special, rare format.&lt;br /&gt;
: This is the output of a mechanical &#039;&#039;&#039;assembly of four AdvaPIX-TPX&#039;&#039;&#039; devices, with &#039;&#039;&#039;four USB cables&#039;&#039;&#039;, which was then presented as the AdvaPIX TPX Quad. Not to be confused with the current AdvaPIX-Quad which has a single USB cable.&lt;br /&gt;
: Even if you have this set, don&#039;t save AMF unless you have a very special reason.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! AMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The amf is a binary file that contains data from all the devices combined into one stream of frame matrixes. The file consists of two parts a header (1000 bytes) and the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two versions of the file. Version 1 and Version 2. Version 1 has only one offset parameter, but had a bug, where frames were shifted in the file by 8 bytes. Version 2 has to frame data offsets - before frame data and after frame data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 1):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 1&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offset; // offset of each frame data in the frame block&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 2):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 2&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offsetBefore; // offset of the beginning of frame data in frame block&lt;br /&gt;
 u32 offsetAfter; // offset after frame data&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file may contain variable number of chips (not only data from AdvaPIX Quad = 4 chips).&lt;br /&gt;
* &#039;&#039;&#039;channelCount&#039;&#039;&#039; - How many chip are present in the file.&lt;br /&gt;
* &#039;&#039;&#039;chipsWidth&#039;&#039;&#039; and &#039;&#039;&#039;chipsHeight&#039;&#039;&#039; - How many chips are in x and y coordinate. For example for AdvaPIX Quad it is 2 by 2 (chipsWith = 2, chipsHeight = 2).&lt;br /&gt;
* &#039;&#039;&#039;chipLayout&#039;&#039;&#039; and &#039;&#039;&#039;chipAngles&#039;&#039;&#039; - When the device is read the order of chips is different than shown on the screen (depending on the layout of the internal chip interconnection). Therefore it is necessary to know AdvaPIX QUAD Multi-Frame Format (*.amf) order of the chips and they rotation to create correct image. chipLayout specifies order of the chip (the indexes starts from 0 to the index of last chip, from the top left to the right bottom). The chipAngles specifies rotation of each chip (0 = no rotation, 1 = 90 deg, 2 = 180, 3 = 270, all clockwise).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After the header file the frame data folows. The frame data are saved in frames blocks. Each block contain frames from each detector.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [FrameBlock1][FrameBlock2][FrameBlock3]...&lt;br /&gt;
Frame Block contains:&lt;br /&gt;
 [FrameData1][FrameData2][FrameData3][FrameData4]....&lt;br /&gt;
Each frame contains:&lt;br /&gt;
 [Offset][MatrixData(65536*2)] // Version 1 of the file&lt;br /&gt;
 [OffsetBefore][MatrixData(65536*2)][OffsetAfter] // Version 2 of the file&lt;br /&gt;
Each frame is prepended by an offset (specified in header, offsetBefore) and appended byt some dummy data of length offsetAfter. The frame pixels are saved as 16 bit unsigned integer. Each chip has 256x256 pixels. Therefore - 65536 * 2 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bug in Version 1 of the AMF File:&#039;&#039;&#039;&lt;br /&gt;
The version 1.0 of the AMF file contains bug, where the first frame in the data is missing first 8 bytes. To compensate in the code, when reading make the length of HEADER smaller by 8 bytes =&amp;gt; 992 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
Version 2 has size of offset before and after frame data instead.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offset;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = (HEADER_SIZE - 8) + offset&lt;br /&gt;
secondFrameDataPosition = (HEADER_SIZE - 8) + offset + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offsetBefore + offsetAfter;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = HEADER_SIZE + offsetBefore&lt;br /&gt;
secondFrameDataPosition = HEADER_SIZE + offsetBefore + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MCF and BPC ==&lt;br /&gt;
Old configuration formats. Was used for pixcfg or DACs. Use only to read old data. If it possible, save all old configurations in newer formats, such as XML, and do not use old files due to possible end of support.&lt;br /&gt;
&lt;br /&gt;
= Other files =&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_configuration_ini_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device configuration ini files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_firmware_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device firmware files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: &#039;&#039;&#039;BSTG files&#039;&#039;&#039;]] or see the &#039;&#039;&#039;Spectraimg and data files&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;User XML settings&#039;&#039;&#039;: See: The &#039;&#039;&#039;ISetting object&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;ASCII vertical *.vtxt&#039;&#039;&#039;: CSV-like file used in [[PIXet EDU|&#039;&#039;&#039;PIXet EDU&#039;&#039;&#039;]] and [[PIXet#Clustering_plugin|&#039;&#039;&#039;Clustering plugin&#039;&#039;&#039;]] for saving histograms&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Files and directories of the Pixet and SDK]]&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1709</id>
		<title>File types</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1709"/>
		<updated>2026-04-09T11:11:25Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* HDF5 files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Summary =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ General image/data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII frame&#039;&#039;&#039;. Text files with img lines converted to text lines with numbers separated by spaces.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pbf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet binary frame&#039;&#039;&#039;. Simple binary files, numbers only.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pmf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet multi frame&#039;&#039;&#039;. Default is same as the txt, but multiple frames on top of each other. Can use BINARY flag.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3pa&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels ASCII&#039;&#039;&#039;. Text, CSV-like format, tab-separated columns with the header in the first row. Biggest to saving.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3p&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels&#039;&#039;&#039;. Binary format. Lower saved size than T3PA, contains simple repeats of 1 structure.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3r&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 raw&#039;&#039;&#039;. Complete data stream of Tpx3 chips. Lahge to saving, difficult to understand, slow to processing and can cause processing errors.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;png&#039;&#039;&#039; || Lossless compressed image. Easy to view, but not good for data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;tiff&#039;&#039;&#039; || &#039;&#039;&#039;TIFF, TIF&#039;&#039;&#039;, high bit-depth file usable in common graphic softwares or data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;h5&#039;&#039;&#039; || &#039;&#039;&#039;HDF5&#039;&#039;&#039;, hierarchical data format 5. Used as one of multi-frame formats.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Files auxilliary for image/data&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;dsc&#039;&#039;&#039; || Text metadata list saved beside a standard multiframe files (PMF for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;info&#039;&#039;&#039; || Text metadata list saved beside other than standard multiframe files (T3PA for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;idx&#039;&#039;&#039; || Binary index for multi-frame files. Two formats existing.&amp;lt;br&amp;gt;&lt;br /&gt;
Usesfull for fast access to n-th frame of large text files, necessary for frame seeking in binary sparse files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Special data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;clog, plog&#039;&#039;&#039; || &#039;&#039;&#039;Clusters/pixels logs&#039;&#039;&#039;. Text files contains clusters separated to frames with pixels lists. Historic formats for saving a data with few hited pixels in a frames. (&#039;&#039;&#039;obsolette&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bstg&#039;&#039;&#039; || &#039;&#039;&#039;Binary settings&#039;&#039;&#039; file. Measured or processed data with all configuration.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: BSTG files]] or see the &amp;quot;Spectraimg and data files&amp;quot; chapter in the Python API manual.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;vtxt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII vertical&#039;&#039;&#039; CSV-like file used in PIXet EDU and Clustering plugin for saving histograms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Configuration files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;xml&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ini&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
: &#039;&#039;&#039;Note&#039;&#039;&#039; Since 2025/09 release &#039;&#039;&#039;format changed&#039;&#039;&#039; to fully standard ini&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;txt&#039;&#039;&#039; ||&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;mcf&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
# DAC settings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bpc&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File type and extensions constants =&lt;br /&gt;
There are constants for file types and extensions. It can be used with [[Python API | &#039;&#039;&#039;Python API&#039;&#039;&#039;]] for filenames testing or with acquisition functions. But &#039;&#039;&#039;mostly PX_FTYPE_AUTODETECT will be enough&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Python example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Python&amp;gt;&lt;br /&gt;
# measure and save one 0.25 second frame to png file named &amp;quot;testFile.png&amp;quot;&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_PNG, &amp;quot;testFile&amp;quot;)&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_AUTODETECT, &amp;quot;testFile.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! colspan=3 | File types and extensions constants table &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! File type constants !! File extensions constants !! Ext value&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_NONE || (No direct file saving – data stored only in memory) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_AUTODETECT || (FTYPE detected by extension in a filename) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_ASCII_FRAME || PX_EXT_ASCII_FRAME || &amp;quot;txt&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_FRAME || PX_EXT_BINARY_FRAME || &amp;quot;pbf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_MULTI_FRAME || PX_EXT_MULTI_FRAME || &amp;quot;pmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_MULTIFRAME || PX_EXT_BINARY_MULTI_FRAME || &amp;quot;bmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS || PX_EXT_TPX3_PIXELS || &amp;quot;t3p&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS_ASCII ||PX_EXT_TPX3_PIXELS_ASCII || &amp;quot;t3pa&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_CLUSTER_LOG || PX_EXT_CLUSTER_LOG || &amp;quot;clog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXEL_LOG || PX_EXT_PIXEL_LOG || &amp;quot;plog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PNG || PX_EXT_PNG || &amp;quot;png&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_RAW_DATA || PX_EXT_TPX3_RAW_DATA || &amp;quot;t3r&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXET_RAW_DATA || PX_EXT_PIXET_RAW_DATA || &amp;quot;prd&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_EXTERNAL || (reserved) ||&lt;br /&gt;
|-&lt;br /&gt;
| (description file saved automatically with pmf/txt) || PX_EXT_FRAME_DESC || &amp;quot;dsc&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| (index file saved automatically with pmf/txt) || PX_EXT_INDEX || &amp;quot;idx&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File saving flags summary =&lt;br /&gt;
File saving flags can do additional settings for file(s) saving.&lt;br /&gt;
* Can be used in &#039;&#039;&#039;saving&#039;&#039;&#039; files or in &#039;&#039;&#039;doAdvancedAcquisition&#039;&#039;&#039; python methods, for example.&lt;br /&gt;
* Flags can be combined.&lt;br /&gt;
* Default frame file settings is set of separate subframes text files, with all pixels include zeros, each subframe with idx+dsc files:&lt;br /&gt;
:: file_ToT.pmf, file_ToT.pmf.dsc, file_ToT.pmf.idx, file_ToA.pmf, file_ToA.pmf.dsc, file_ToA.pmf.idx&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ File saving flags&lt;br /&gt;
|-&lt;br /&gt;
! Flag constant base name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_BINARY || Use binary format in pmf.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEX || Index + non-zero pixels in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEXY || X, Y + non-zero pixel in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NODSC || Do not add dsc file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NOSUBFRAMES || Do not use subframes, save main frame only.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_ONEFILE || Save all subframes to a single file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME || Save separate all subframes and main frame extra.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The file saving flags can be used in&lt;br /&gt;
* &#039;&#039;&#039;Python API&#039;&#039;&#039;: Use pixet.PX_FRAMESAVE_... constants in flags parameter of some measuring/saving methods.&lt;br /&gt;
* &#039;&#039;&#039;Binary API&#039;&#039;&#039;: Use PX_FRAMESAVE_... constants in flags parameter of some measuring functions.&lt;br /&gt;
* The Pixet program. Available in the &#039;&#039;&#039;More measurement settings, after compatible filename was selected&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:File-flags-dialog.png|frame|alt=File saving flags in More measurement settings in Pixet|File saving flags in More measurement settings in Pixet]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File extensions and flags: TXT/PBF/PMF details =&lt;br /&gt;
&lt;br /&gt;
== The files formats ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;width:50px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Text&#039;&#039;&#039; || Single frame in the text file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pbf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Binary&amp;amp;nbsp;Frame&#039;&#039;&#039; || Single frame in the binary file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pmf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Multi&amp;amp;nbsp;Frame&#039;&#039;&#039; || Multiframe file with text or binary format, depends on flags used with saving.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;idx&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Index&#039;&#039;&#039; || Binary array of structs with 64b pointers to start of frames, frame metadata and subframes.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;dsc&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Description&#039;&#039;&#039; || List of all metadata for each frame and subframe. Actual device and acquisition parameters, data types, etc. The &amp;quot;Frame name&amp;quot; item can be helpful to orientation in pmf structure if the ONEFILE flag used. The Type=item is helpful to understanding the structure of data if the BINARY flag used.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi-files names generation ==&lt;br /&gt;
; Note:&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; flags 0 (default), input filename = &amp;quot;name&amp;quot;, acqCount = 1&lt;br /&gt;
: name_ToA.txt, name_ToA.txt.dsc, name_ToT.txt, name_ToT.txt.dsc&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; acqCount = 6:&lt;br /&gt;
: name_0_ToA.txt, name_0_ToA.txt.dsc, name_0_ToT.txt, ...&lt;br /&gt;
: ...&lt;br /&gt;
: name_5_ToA.txt, name_5_ToA.txt.dsc, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PMF note&lt;br /&gt;
: With each pmf generating &#039;&#039;&#039;.pmf.idx&#039;&#039;&#039; binary file, other is same as TXT with acqCount = 1.&lt;br /&gt;
&lt;br /&gt;
== Files with flags=0 ==&lt;br /&gt;
; Note&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; TXT file data, default&lt;br /&gt;
: 0 0 0 5 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0 872 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: (256 lines)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PBF file data, default&lt;br /&gt;
: Simple pixels binary data without anything else&lt;br /&gt;
: Data can be typically 16 or 32 bit raw integers with little-endian order and doubles for calibrated data.&lt;br /&gt;
: For example, MiniPIX has single chip, this has 65536 pixels, it&#039;s binary file has 65536 words (size 128 kB binary), sometimes 65536 doubles (size 512 kB binary).&lt;br /&gt;
: The &#039;&#039;&#039;data format&#039;&#039;&#039; can be read in the line starting with Type= line in the [[#DSC files details | &#039;&#039;&#039;DSC file&#039;&#039;&#039;]] saved beside the data file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PMF file data, default&lt;br /&gt;
: 0.00000 78.65742 0.00000 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0.00000 0.00000 999785.5 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter &lt;br /&gt;
: (256 lines * acqCount)&lt;br /&gt;
&lt;br /&gt;
== Flags influence to files ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEX flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| _ToA.txt file !!colspan=&amp;quot;2&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 227212.500000 || 0 || 20&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 310685.937500 || 17 || 13&lt;br /&gt;
|-&lt;br /&gt;
| 255 || 265487.500000 || 255 || 11&lt;br /&gt;
|-&lt;br /&gt;
| 1274 || 105728.125000 || 1274 || 9&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;4&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEXY flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;3&amp;quot;| _ToA.txt file !!colspan=&amp;quot;3&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 247 || 3 || 189851.562500 || 247 || 3 || 16&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 4 || 140042.187500 || 250 || 4 || 12&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 9 || 317195.312500 || 5 || 9 || 5&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;6&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;6&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;PMF file data, pixet.PX_FRAMESAVE_SPARSEX(Y) flag&#039;&#039;&#039;&amp;lt;br&amp;gt;Same as TXT, but containing single lines with only # to separate frames&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! X !! Y !! ToA !! Line description&lt;br /&gt;
|-&lt;br /&gt;
| 232 || 139 || 321620.312500 || frame 1, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 252 || 340231.250000 || frame 1, px 2&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;3&amp;quot;| # || frames separator&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 0 || 258270.312500 || frame 2, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 201 || 0 || 76593.750000 || frame 2, px 2&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 1 || 268642.187500 || frame 2, px 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_ONEFILE&lt;br /&gt;
: All the data is in one file, subframes are placed one behind the other. If the measurement result has 10 frames with 2 subframes A/B, each _n TXT file contains 2 subrfames and the PMF contains 20 frames in order:&lt;br /&gt;
: sfr0A, sfr0B, sfr1A, sfr1B, ...&lt;br /&gt;
: The exact order and names of type of (sub)frames is listed in the DSC file. The DSC have separate records [Fn] for all the items.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME&lt;br /&gt;
: The group of the saved files contains the main frame and all subframes. Subframe files end in _sfrName, the main frame does not. In DSC file accompanying the TXT with main frame is not the &amp;quot;Frame name&amp;quot; item.&lt;br /&gt;
: Not applicable if combined with the &#039;&#039;&#039;ONEFILE&#039;&#039;&#039; flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_BINARY&lt;br /&gt;
: If the file type supports text and binary format, ex. PMF, save the binary.&lt;br /&gt;
: Not applicable to TXT, must use PBF instead.&lt;br /&gt;
: Data in the file are the simple array of non-calibrated 16 or 32b integers or calibrated doubles. See the DSC file for used data type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BINARY + SPARSEXY examples:&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
[[File:File-binary-sparsexy-example.png|frame|none|alt=Example of data saved if flags BINARY+SPARSEXY used|Example of data saved if flags BINARY+SPARSEXY used]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Timepix3 specific data files =&lt;br /&gt;
The Timepix3 have the data-driven mode feature. It is &amp;quot;frameless&amp;quot; mode, where the device can continuously send the data of the pixels just hit indefinitely. Each sent pixel contains information:&lt;br /&gt;
# Pixel position index&lt;br /&gt;
# Event registration time (raw ToA count and FToA, conversion and corrections needed)&lt;br /&gt;
# Energy deposited in a pixel (raw ToT count, need conversion using the chip-specific calibration table containing cal. constants for each pixel)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Theese files can be very large. You can collecting a data from cosmic particles using Minipix continuously for more weeks and get a T3PA sized in tens of megabytes. But if some noising pixel occurs, a files can has many gygabytes per day. If the Advapix used with x-ray mashines or accelerators, the output data can has gigabytes in an instant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The formats:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;T3PA&#039;&#039;&#039; files are &#039;&#039;&#039;text/csv&#039;&#039;&#039; files with basic data. User can simply see it in text editor and process it in Python etc.&lt;br /&gt;
* &#039;&#039;&#039;T3P&#039;&#039;&#039; files are &#039;&#039;&#039;binary&#039;&#039;&#039; files with basic data same as T3PA. Faster saving, shorter files.&lt;br /&gt;
* &#039;&#039;&#039;T3R&#039;&#039;&#039; files are binary files with complete raw communication data. &#039;&#039;&#039;For special purposes only.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data order&#039;&#039;&#039;&lt;br /&gt;
* The order of the data roughly corresponds to the order of events, so data an hour later will definitely be further in the file.&lt;br /&gt;
* But the exact order corresponds to the order in which the data came from the device, so for example a later event that occurred at the edge where the chip is read can be recorded earlier than an earlier event that occurred further from the edge.&lt;br /&gt;
* The unevenness of the order occurs from tens of ns on a lightly loaded Advapix to several ms with a heavy load on the Minipix.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;How to get the files:&#039;&#039;&#039;&lt;br /&gt;
* In the [[PIXet|&#039;&#039;&#039;Pixet&#039;&#039;&#039;]] program set operation mode to ToA+ToT and use the &amp;quot;Pixels&amp;quot; measurement type and turn on file saving.&lt;br /&gt;
* In the [[Binary_core_API|&#039;&#039;&#039;binary API&#039;&#039;&#039;]] using programs set operation mode to PXC_TPX3_OPM_TOATOT and use the [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]] function.&lt;br /&gt;
* In the [[Python API|&#039;&#039;&#039;Python API&#039;&#039;&#039;]] using programs set operation mode to pixet.PX_TPX3_OPM_TOATOT and use the dev.&#039;&#039;&#039;doAdvancedAcqquisition&#039;&#039;&#039; with acqType=pixet.PX_ACQTYPE_DATADRIVEN.&lt;br /&gt;
&lt;br /&gt;
== T3PA files details ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 pixels ASCII file&#039;&#039;&#039; is timepix3 data file in text format with lines and tabs. Can be read as CSV, but its size is not limited to sizes readable by Office-like programs . Contains the header line and data lines with record index, pixel index in the matrix, Time of arrival, Time over threshold, Fine ToA and Overflow.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The T3PA example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Index   Matrix Index    ToA     ToT     FToA    Overflow&lt;br /&gt;
0       1028    1918    14      22      0&lt;br /&gt;
1       1028    3126    8       28      0&lt;br /&gt;
2       1028    3778    5       23      0&lt;br /&gt;
...&lt;br /&gt;
156003  39793   98473646054     38      9       0&lt;br /&gt;
156004  190     98492090610     19      3       0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Index&#039;&#039;&#039; is simple index of measurement line. This growing while measurement is running. If you append new measurement to existing file, new index is 0 again and again growing while new measurement is running.&lt;br /&gt;
[[File:Minipix-pixel00.png|frame|right|alt=Physical position of the x=0, y=0 pixel on the Minipix|Physical position of the x=0, y=0 pixel on the Minipix]]&lt;br /&gt;
* The &#039;&#039;&#039;Matrix Index&#039;&#039;&#039; is index of the pixel. On the Minipix Tpx3 is 0 at the left-down (see image)&lt;br /&gt;
* The &#039;&#039;&#039;ToA&#039;&#039;&#039; is time of arrival in units 25 ns, mod by limit specific by device type.&lt;br /&gt;
:: For example Minipix 2&amp;lt;sup&amp;gt;64&amp;lt;/sup&amp;gt; (14600y), Advapix-single 2&amp;lt;sup&amp;gt;30&amp;lt;/sup&amp;gt; (26s), Advapix-Quad 2&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (6.5s).&lt;br /&gt;
: &#039;&#039;&#039;Note:&#039;&#039;&#039; The ToA on-chip implementation in the pixels is limited to 14 bits (409.6 µs).&lt;br /&gt;
:: The ToA in T3PA is extended by device. But there is inherent uncertainty around the borders. These values may be incorrectly assigned. Users not comfortable with our extension can apply AND with (uint64)16383 to extended ToA to get original ToA from the chip.&lt;br /&gt;
* The &#039;&#039;&#039;ToT&#039;&#039;&#039; is time over threshold in units 25 ns.&lt;br /&gt;
* The &#039;&#039;&#039;FToA&#039;&#039;&#039; stands for &amp;quot;fine ToA&amp;quot; and it is the finest step of the ToA measurement. To properly account for this step in the conversion of ToA to time, it is necessary to subtract the amount of counts of fToA in the following manner:&lt;br /&gt;
:: &#039;&#039;&#039;Time [ns] = 25*ToA - (25/16)*fToA&#039;&#039;&#039;&lt;br /&gt;
: The original range of this fToA value in the chip is 4 bits, or 16 values. This is extended in the post-processing of the data into 5 bits, or 32 values to include a correction for Intentional phase shift of clocks propagated into the columns of the chip. The final value exported into t3pa files has a range of 5 bits, or 32 values, but the previous equation still stands.&lt;br /&gt;
* The &#039;&#039;&#039;Overflow&#039;&#039;&#039; is sign of data transfer overflow or other special cases.&lt;br /&gt;
:: &#039;&#039;&#039;Note:&#039;&#039;&#039; In data from multichip devices, there is not Overflow, replaced by Chip index (=copy of bits 16+ of Matrix Index. But column name is still Overflow).&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;1 - data transfer overflow&#039;&#039;&#039;:&lt;br /&gt;
::: matrix index = 0x74: start of lost data&lt;br /&gt;
::: matrix index = 0x75: end of lost data, toa is length of the missing time&lt;br /&gt;
::: (this can occurs with rates over megahits per seconds for Minipix)&lt;br /&gt;
::: matrix index = 0: Data corruption event detected - all next data can be corrupted&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;10 - trigger timestamp&#039;&#039;&#039; (If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled):&lt;br /&gt;
::: matrix index = 0, ToT = 0&lt;br /&gt;
::: ToA = Timestamp of arrival external sync pulse to the device.&lt;br /&gt;
::: FToA = Count of expected ToA counter overflows.&lt;br /&gt;
::: If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, every sync pulse cause creating of one line record, independent of sync is or is not used to start of the acquisition. Timestamps can be recorded some time before the measurement starts. They may have zero or, conversely, an arbitrarily high value.&lt;br /&gt;
::: Warnings:&lt;br /&gt;
:::* Be careful about having too high values ​​in the FToA column (increment every 409.6 µs).&lt;br /&gt;
:::* Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&lt;br /&gt;
&lt;br /&gt;
* Related: [[The_RawTpx3Pixel_structure_in_memory#Explanation_of_the_struct|The RawTpx3Pixel structure in memory: Explanation of the struct]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If &#039;&#039;&#039;saving of the T3PA repeated to the same file&#039;&#039;&#039;, new data will be append with new reset of record index and ToA and the file containing parts is like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
507812	353	39993345	1022	15	0&lt;br /&gt;
507813	46177	39999843	159	2	0&lt;br /&gt;
507814	45921	39999843	159	2	0&lt;br /&gt;
0	421	2	13	29	0&lt;br /&gt;
1	297	2	22	27	0&lt;br /&gt;
2	297	145	62	17	0&lt;br /&gt;
3	297	283	19	13	0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3P files details ==&lt;br /&gt;
&#039;&#039;&#039;Timepix3 Binary Pixels&#039;&#039;&#039; is similar to t3pa file without record index. And the numbers are not saved as ASCII, but binary. The file contains one pixel after each other. Each pixel in this format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 matrixIdx;&lt;br /&gt;
u64 toa;&lt;br /&gt;
byte overflow;&lt;br /&gt;
byte ftoa;&lt;br /&gt;
u16 tot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P file contents example:&#039;&#039;&#039;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ As see in a HEX editor&lt;br /&gt;
|- &lt;br /&gt;
| 5E86 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0300&lt;br /&gt;
|-&lt;br /&gt;
| 6087 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 6387 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 001B || 0100&lt;br /&gt;
|-&lt;br /&gt;
| 6486 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 5D84 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0010 || 0200&lt;br /&gt;
|-&lt;br /&gt;
| 89BD || 0000 || 240B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0D00&lt;br /&gt;
|-&lt;br /&gt;
| 5F80 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0002 || 0600&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ Redistributed according the structure&lt;br /&gt;
|-&lt;br /&gt;
! pxIdx&amp;lt;br&amp;gt;4 B !! ToA&amp;lt;br&amp;gt;8 B !! Over&amp;lt;br&amp;gt;1 B !! fToA&amp;lt;br&amp;gt;1 B !! ToT&amp;lt;br&amp;gt;2 B&lt;br /&gt;
|-&lt;br /&gt;
| 5E 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 03 00&lt;br /&gt;
|-&lt;br /&gt;
| 60 87 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 63 87 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 1B || 01 00&lt;br /&gt;
|-&lt;br /&gt;
| 64 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 15 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 5D 84 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 10 || 02 00&lt;br /&gt;
|-&lt;br /&gt;
| 89 BD 00 00 || 24 0B 00 00 00 00 00 00 || 00 || 15 || 0D 00&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Corresponding start of T3PA&lt;br /&gt;
: Index &amp;amp;nbsp;	Matrix Index &amp;amp;nbsp;	ToA &amp;amp;nbsp;	ToT &amp;amp;nbsp;	FToA &amp;amp;nbsp;	Overflow&lt;br /&gt;
: 0  &amp;amp;nbsp; 34398  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 3  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 1  &amp;amp;nbsp; 34656  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 2  &amp;amp;nbsp; 34659  &amp;amp;nbsp; 2847   &amp;amp;nbsp; 1  &amp;amp;nbsp; 27 &amp;amp;nbsp; 0&lt;br /&gt;
: 3  &amp;amp;nbsp; 34404  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 21 &amp;amp;nbsp; 0&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;Overflow value&#039;&#039;&#039; - Data transfer overflow indicator or other special value indicator.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#T3PA files details]] for details and see below for T3P differences in the trgTimeStamp.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P files with trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Note: This is old internal testing feature and was not intended for mormal using. If you do want to use it, here&#039;s some info:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, file can contains lines of tab-divided ASCII numbers. Every record is six numbers divided by tabs (0x09) and ended with line end (0x0A).This is simple T3PA line. See the T3PA with overflow=10 for details.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every sync pulse cause creating of one line record. In the file, each sync record and each pixel are simply stored in the order as it arrived on the computer. Any combination of order and number of binary and text records can be expected.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This is a source of complications when using the file. The file must be browsed sequentially as binary pixels. At the first occurrence of faulty or suspicious values (eg high pixel index, high ToA, Overflow&amp;gt;1) assume that the current record is not a pixel, but that the ASCII/tab line starts here and that it ends at 0A.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3R files ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 Raw Data File&#039;&#039;&#039; is special format for testing purposes. This is a dump of raw communication from the device. The file format is device specific, binary, complex and files are very large. Use this only if you have no other option.&lt;br /&gt;
&lt;br /&gt;
= DSC/INFO metadata files =&lt;br /&gt;
The metadata text files are saved beside the data files and containing informations about device and settings used for measuring the data. It can be usable while openning the data file in the Pixet program or in other working with the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the API is used to saving the data, programmer can use callback like us &amp;quot;&#039;&#039;&#039;before saving data callback&#039;&#039;&#039;&amp;quot; to add Your specific metadata items or can remove items that will not need.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;DSC&#039;&#039;&#039; are files generated beside the frame data and cotaining information for each frame&lt;br /&gt;
* &#039;&#039;&#039;INFO&#039;&#039;&#039; are files generated beside pixel data and some special data formats&lt;br /&gt;
&lt;br /&gt;
== DSC files details ==&lt;br /&gt;
The first line is &#039;&#039;&#039;header line&#039;&#039;&#039;:&lt;br /&gt;
: Some like as &#039;&#039;&#039;A123456789&#039;&#039;&#039;: B=binary / A=ASCII and number = count of frames in multiframe data file&lt;br /&gt;
Next are &#039;&#039;&#039;frames&#039;&#039;&#039; in format:&lt;br /&gt;
: &#039;&#039;&#039;1. [Fn]&#039;&#039;&#039; - Frame with idx n start: [F0], [F1], ...&lt;br /&gt;
: &#039;&#039;&#039;2. Frame type&#039;&#039;&#039; - Data type, pixel format and frame size: Some like as &amp;quot;Type=i16 [X,C] width=256 height=256&amp;quot;&lt;br /&gt;
:: Pixels format options:&lt;br /&gt;
::: &#039;&#039;&#039;matrix&#039;&#039;&#039; - Whole matrix saved. Number of saved pixels are allways width*height.&lt;br /&gt;
:::: Multiframe data file not contains frame separator.&lt;br /&gt;
::: &#039;&#039;&#039;[X,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has matrix index and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
::: &#039;&#039;&#039;[X,Y,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has X,Y position and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
: &#039;&#039;&#039;3. Frame metadata&#039;&#039;&#039; - List of metadata items separated by blank lines:&lt;br /&gt;
::: Each metadata item is line triplet:&lt;br /&gt;
:# &amp;quot;Item name&amp;quot; (&amp;quot;Item description&amp;quot;): Example: &amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
:# DataType[valCount] Example: double[1]&lt;br /&gt;
:# Values list Example: 0.500000&lt;br /&gt;
:# (blank line)&lt;br /&gt;
: &#039;&#039;&#039;4. (blank line)&#039;&#039;&#039; - end of frame (there are two blank lines, the last metadata item end and the frame end)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In &#039;&#039;&#039;txt.dsc&#039;&#039;&#039; and &#039;&#039;&#039;pbf.dsc&#039;&#039;&#039;, end of the frame is end of the file.&amp;lt;br&amp;gt;&lt;br /&gt;
In the &#039;&#039;&#039;pmf.dsc&#039;&#039;&#039;, next frames or subframes metadata follows.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Some example (PBF 1 frame, with BINARY and SPARSEXY – test_49_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001                                      B=binary / A=ASCII and number = count of frames in multiframe file&lt;br /&gt;
[F0]                                            Index of frame in the file = 0&lt;br /&gt;
Type=double [X,Y,C] width=256 height=256        Data type double, X,Y,C = only hit pixels saved and has XY pos.&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):  Some metadata item name and (description)&lt;br /&gt;
u32[1]                                          Type of the item data [number of values]&lt;br /&gt;
49                                              The value&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA                                             This is the ToA frame&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
(end of the file)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Other example (PMF 10 frames, with BINARY+SPARSEX+ONEFILE – test.pmf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000010&lt;br /&gt;
[F0]                                            Start of the first subframe&lt;br /&gt;
Type=double [X,C] width=256 height=256          Pixel index and double type pixel data (ToA in ns)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA &lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[F1]                                            Start of the second subframe&lt;br /&gt;
Type=i16 [X,C] width=256 height=256             Pixel index and i16 type pixel data (ToT in ticks 40MHz)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
(and the ToT frame metadata, [F2] and ToA subframe, [F3] and ToT sfr, … [Fn] and ToT sfr of (n/2)th frame)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Complete one frame DSC example (PMF 1 frame, BINARY+SPARSEX – test_15_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001&lt;br /&gt;
[F0]&lt;br /&gt;
Type=double [X,C] width=256 height=256&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
15&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059034.903085 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
0.500000&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
I08-W0060&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1301 501 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-500 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.7.8&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059042.934810 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Thu Dec 9 15:10:42.934809 2021&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.026744&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== INFO files details ==&lt;br /&gt;
* The T3PA.INFO containing metadata in format very similar to one frame of DSC file.&lt;br /&gt;
* Some other INFO files can containing simpliest formated metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;T3PA.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[FileInfo]&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.719000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1.000000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
D06-W0065&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1237 437 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-450 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.8.1&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Shutter open time&amp;quot; (&amp;quot;Shutter open timestamp&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Tue Jan  9 15:12:18.867000 2024&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.015797 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;BMF.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[File Meta Data]&lt;br /&gt;
Acq Serie Index:0&lt;br /&gt;
Acq Serie Start time:1704813831.469&lt;br /&gt;
Acq time:0.001&lt;br /&gt;
ChipboardID:G03-W0259&lt;br /&gt;
DACs:10 100 255 127 127 0 153 6 130 100 80 85 128 128&lt;br /&gt;
HV:-450&lt;br /&gt;
Interface:AdvaPIX&lt;br /&gt;
Mpx type:2&lt;br /&gt;
Pixet version:1.8.1&lt;br /&gt;
Start time:1704813831.633&lt;br /&gt;
Start time (string):Tue Jan  9 16:23:51.633000 2024&lt;br /&gt;
Threshold:5.02649397407217&lt;br /&gt;
Timepix clock:50&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= IDX files details =&lt;br /&gt;
The IDX files are generated with multiframe files to help with fast seeking frames in files. &#039;&#039;&#039;Each frame except first&#039;&#039;&#039; has the basic structure in the IDX file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct IndexItem {&lt;br /&gt;
 i64 dscPos;    // frame position in the DSC file&lt;br /&gt;
 i64 dataPos;   // frame position in the main data file&lt;br /&gt;
 i64 sfPos;     // subframe position if exist subframes file next to the main data file (usually not and =0)&lt;br /&gt;
};&lt;br /&gt;
// Note: CLOG.IDX has no this structure, this in only i64 pointers to frames&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;PMF.IDX&#039;&#039;&#039; files generated beside the PMFs. Contains the simple binary array of structs of 3 little-endian qwords with addresses associated to the start of each frame except first: DSC, frame and subframe.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
; .pmf.idx with BINARY+ONEFILE, ToA+ToT example&lt;br /&gt;
: main data contains&lt;br /&gt;
:* ToA subframes (double*0x10000 = len 0x80000)&lt;br /&gt;
:* ToT subframes (i16*0x10000 = len 0x20000)&lt;br /&gt;
The IDX contains&lt;br /&gt;
# Pointers to frames in DSC file at 0 (not in idx), 0x03B5, 0x075D, 0x0B08, 0x0BE0, ... (points to an empty line before [Fx] line)&lt;br /&gt;
# Pointers to frames in main data file at 0 (not in idx), 0x080000, 0x0A0000, 0x120000, 0x140000, 0x1C0000, ...&lt;br /&gt;
# Pointers to frames in additional subframes file (not exist -&amp;gt; all=0)&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-pmf-idx-example.png|frame|right|alt=.pmf.idx file example|.pmf.idx file example]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= HDF5 files =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The HDF5 (&#039;&#039;&#039;.H5&#039;&#039;&#039;) files are general standard binary containers for structured data. If used to save, contains both measured data and metadata.&lt;br /&gt;
* To access theese files, use third party tools like as:&lt;br /&gt;
:* &#039;&#039;&#039;HDFview&#039;&#039;&#039; from HDF Group&lt;br /&gt;
:* &#039;&#039;&#039;h5py&#039;&#039;&#039; python library from HDF Group&lt;br /&gt;
:: See: [[Python_API#Examples|&#039;&#039;&#039;Python API: Examples&#039;&#039;&#039;]] for reading using Python&lt;br /&gt;
:* &#039;&#039;&#039;HDF5 C++ API&#039;&#039;&#039; from HDF Group&lt;br /&gt;
* If you are saving from the API without Pixet, the &#039;&#039;&#039;hdf5io.dll&#039;&#039;&#039; plugin must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the hdf5io plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:left; vertical-align:top;&amp;quot;| The plugin file must exist in the directory:&lt;br /&gt;
| [[File:Plugin-hdf5.png|thumb|alt=HDF5 plugin file in plugins directory|HDF5 plugin file in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Saving a HDF5 files ==&lt;br /&gt;
* The files can be saved from the Pixet program or by API.&lt;br /&gt;
: [[File:Files-hdf5-saving-pixet.png|frame|none|alt=Saving HDF5 from the Pixet program|Saving HDF5 from the Pixet program:&amp;lt;br&amp;gt;First was saved the &#039;&#039;&#039;test.h5&#039;&#039;&#039;, second the &#039;&#039;&#039;test.h5:meas2&#039;&#039;&#039;]]&lt;br /&gt;
* When saving to an existing file, the data is added to the existing structure in it.&lt;br /&gt;
* Use the AUTODETECT filetype in the API functions using filetype.&lt;br /&gt;
* Saving flags will be ignored.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Next image showing 3 files in the HDFview program&lt;br /&gt;
# File test1.h5 saved by acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
# File test2.h5 saved by tripple acquisitions of 10 frames, with filename settings &amp;quot;test1.h5:set0&amp;quot;,  &amp;quot;test1.h5:set1&amp;quot; and  &amp;quot;test1.h5:set2&amp;quot;.&lt;br /&gt;
# File test1.h5, existing from first acq., saved again in next acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-hdf5-examples.png|frame|none|alt=HDF5 files examples in HDFview|HDF5 files examples in HDFview: Single acq. with 10 frames, triple with structure, first file after second acq.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The files was saved from the PY script:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=Python start=60&amp;gt;&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set0&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set1&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set2&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pixet structures in HDF5 ==&lt;br /&gt;
As see at the &amp;quot;HDF5 files examples&amp;quot; image in the previous chapter, the acquisition creates the file with structure (or adds to existing):&lt;br /&gt;
# Root name or path if defined by adding :hdfpath at end of filename (optional)&lt;br /&gt;
# Frame list: Frame_0, Frame_1, ...&lt;br /&gt;
# Main frame data: The Data item&lt;br /&gt;
# Basic informations items: AcqTime, Width, Height, StartTime&lt;br /&gt;
# MetaData directory containing same data as saved to the dsc files alongise classic simple data files.&lt;br /&gt;
# SubFrames directory with subframes subdirs named by subframe names (ToA, ToT, Event, iToT, ...) containing same structures as the main frame.&lt;br /&gt;
&lt;br /&gt;
= TIFF images =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The TIFF (&#039;&#039;&#039;.TIFF / .TIF&#039;&#039;&#039;) &amp;quot;Tag Image File Format&amp;quot;, files are image format for high-resolution and high-bitDepth data and has multi-page support. If used to save, contains measured data in 32 bit integer format.&lt;br /&gt;
* If saving from API without the Pixet program, the &#039;&#039;&#039;tiffio.dll plugin&#039;&#039;&#039; must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]* Note: Multipage format is not yet supported in Pixet. &lt;br /&gt;
* To simplify further data processing, Pixet saving an integer data only in 32bit format without any conversion. Or if data is double/float, the conversion factor is used (change it in the File output tab on Measurement settings dialog).&lt;br /&gt;
* To facilitate processing, an &#039;&#039;&#039;auxiliary file .tiff.aux.xml&#039;&#039;&#039; is also saved with the image. Note: Contents are completelly different from DSC/INFO files.&lt;br /&gt;
* It very often happens that integer data has negligible values ​​against the range of 32 bits (over 4 billion). This can cause the image &#039;&#039;&#039;looks like completely black&#039;&#039;&#039; when viewed in some programs, even though it contains data.&lt;br /&gt;
* The image can be shown in the Pixet. Drag-drop the image to the image zone. Recommended view settings: Auto range / Smart&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the tiffio plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|[[File:Plugin-tiff.png|thumb|alt=TIFF plugin files in plugins directory|TIFF plugin files in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Configuration files =&lt;br /&gt;
Ecosystem of the Pixet software containing many configuration files and formats. Part of this was inherited from the old Pixelman program. Do not use formats marked OBSOLETE to save new data. Load old data and save it to new formats before support ends.&lt;br /&gt;
&lt;br /&gt;
== Calibration files ==&lt;br /&gt;
# Threshold DAC/energy curves of every pixel are different. For proper device function the threshold adjustment matrix needed. This data is part of the pixel matrix configuration and it is part of the device XML config file.&lt;br /&gt;
# If the readout chip supports energy measuremnts, You need calibration data for convert digital data to the energy in keVs. Every pixel has own calibration coeficients. It&#039;s values depends on sensor chip local differences.&lt;br /&gt;
::* Calibration in the device config file - simpliest variant. The device config file contains calibration section with encoded binary data.&lt;br /&gt;
::* Set of the calibration files - files named name_a.txt, name_b.txt, name_c.txt and name_t.txt. Data is in the text matrix like in the frame files.&lt;br /&gt;
::* Most functions support using filename &amp;quot;name.xml&amp;quot; or &amp;quot;name_a.txt|name_b.txt|name_c.txt|name_t.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix configuration files ==&lt;br /&gt;
Contains matrix of:&lt;br /&gt;
# threshold adjustment bits of the pixel&lt;br /&gt;
# if the pixel is masked&lt;br /&gt;
# if test is on&lt;br /&gt;
# other bits depending on the chip type&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Overview&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;nbsp;&#039;&#039;&#039;bpc&#039;&#039;&#039;&amp;amp;nbsp;&lt;br /&gt;
|| &#039;&#039;&#039;Binary Pixel Configuration&#039;&#039;&#039; || All PM config in one file, meaning of the bits depends on the chip.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Mask Matrix&#039;&#039;&#039; || Text file with pixel mask&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Test Bit Matrix&#039;&#039;&#039; || Text file with test bits&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii THL adj. bits Matrix&#039;&#039;&#039; || Text file with threshold values adjustment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== XML format ==&lt;br /&gt;
Standard XML files&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== INI format ==&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: The original implementation in Pixet environment &#039;&#039;&#039;was non-standard&#039;&#039;&#039;. Older files have sections, such as [hwlibs], which contain values ​​themselves without name= beginnings.&lt;br /&gt;
: Starting &#039;&#039;&#039;from 2025/09 we are switching to standard INI&#039;&#039;&#039;. In sections where previously item beginnings were missing, we have switched to named items, where the name does not matter.&lt;br /&gt;
&lt;br /&gt;
== TXT format ==&lt;br /&gt;
All except DAC settings is simple matrix with lines containing numbers separated by spaces.&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Obsolete files =&lt;br /&gt;
All formats in this chapter are obsolete and, with the exception of CLOG, has not used for long time and it is possible that their support will be removed.&lt;br /&gt;
Pay attention to possible ambiguities when using CLOG.&lt;br /&gt;
&lt;br /&gt;
== CLOG and PLOG files ==&lt;br /&gt;
Old text formats from age of the first Timepix chips. Due to the new use with Tpx3, new ambiguities in CLOG have arisen.&lt;br /&gt;
* &#039;&#039;&#039;CLOG&#039;&#039;&#039; (clusters log) has remained popular in the context of cluster processing.&lt;br /&gt;
* &#039;&#039;&#039;PLOG&#039;&#039;&#039; (pixels log) is currently no longer used.&lt;br /&gt;
&lt;br /&gt;
=== CLOG and CLOG.IDX files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
The CLOG format was developed to facilitate further processing of cluster data by the user programs. This is a text file divided to the frame records and the records can contain a clusters. Frames and clusters are separated by the line breaks. Frames can be separated by whole free line.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The record format&lt;br /&gt;
: Frame FN (frameStart, frameAcqTime s)&lt;br /&gt;
: [x, y, energy, ToA] [x, y, energy, ToA] [x, y, energy, ToA] ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;FN&#039;&#039;&#039; || Frame index number. First 0 or 1.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameStart&#039;&#039;&#039; || Start time of the frame. There are variants:&lt;br /&gt;
1. If it from measuring or from replay frame-based data with metadata available:&lt;br /&gt;
: Linux format, frame starting time from PC’s getPrecisionTime.&lt;br /&gt;
2. If it from pixel-based data with metadata available (file.t3pa + file.t3pa.info):&lt;br /&gt;
: Linux format, acq. starting time from PC’s getPrecisionTime with added time from data.&lt;br /&gt;
3. If it from replay data and metadata not available:&lt;br /&gt;
: Nanoseconds from the input data.&lt;br /&gt;
: Periodic increments if source is frame-based, random increments if source is data-driven.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameAcqTime&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; || Duration of the frame, float in seconds. Always 0.000000 in data from data-driven sources.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;x, y&#039;&#039;&#039; || Position of the pixel.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;energy&#039;&#039;&#039;* || Energy deposited in the pixel. Integer ToT counter value if not calibrated, float in keV if calibrated.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;ToA&#039;&#039;&#039;* || Time of arrival, relative to frameStart. Integer in CLK ticks if ToA conversion is disabled, float in ns if ToA conversion is enabled.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;*&#039;&#039;&#039;ToA+energy records can be created from source that supports combined ToA+ToT modes, like as OPM_TOATOT on the Timepix3. If the data source supports only single modes, only one value is in this position.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;data-driven&#039;&#039;&#039; source &#039;&#039;&#039;not&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;frame-based&#039;&#039;&#039; source &#039;&#039;&#039;can&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix3, Frame2 with two clusters by 2 and 4 pixels, Frame3 with single 2-pixel cluster)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 2 (273697060.937500, 0.000000 s)&lt;br /&gt;
[214, 195, 43.1598, 0] [220, 191, 20.6515, 7.8125]&lt;br /&gt;
[224, 182, 21.8018, 31.25] [223, 186, 4.58576, 31.25] [222, 183, 38.2381, 31.25] [226, 185, 14.7623, 34.375]&lt;br /&gt;
&lt;br /&gt;
Frame 3 (371034565.625000, 0.000000 s)&lt;br /&gt;
[151, 33, 32.5745, 0] [151, 34, 13.8135, 17.1875]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 6 (1639143482.765164, 0.200000 s)&lt;br /&gt;
[87, 134, 5.75352] [217, 58, 14.8396]&lt;br /&gt;
Frame 7 (1639143483.019154, 0.200000 s)&lt;br /&gt;
Frame 8 (1639143483.261158, 0.200000 s)&lt;br /&gt;
Frame 9 (1639143483.513150, 0.200000 s)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| The &#039;&#039;&#039;CLOG.IDX&#039;&#039;&#039; files generated beside the CLOGs. Contains the simple binary array of little-endian qword addresses of the &amp;quot;F&amp;quot; at each record start.&amp;lt;br&amp;gt;&lt;br /&gt;
; .clog.idx example&lt;br /&gt;
: Pointers to records at 0, 0x29, 0x52, 0x7b, 0xA4, 0xCD, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The &#039;&#039;&#039;CLOG.IDX is different&#039;&#039;&#039; from ordinary ones [[#IDX files details|IDX files]].&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-clog-idx-example.png|frame|alt=Example .clog.idx file|Example .clog.idx file]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== PLOG files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Like as CLOG&#039;&#039;&#039;, but with simple lists of hit pixels of a frames.&lt;br /&gt;
* &#039;&#039;&#039;Metatdata section&#039;&#039;&#039; at start.&lt;br /&gt;
* &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format usable only with &#039;&#039;&#039;Timepix&#039;&#039;&#039; (first generation) chips.&lt;br /&gt;
:: Saved data are main frame only.&lt;br /&gt;
:: IDX is like CLOG.IDX, but items points to [ at start of each frame.&lt;br /&gt;
:: Recommended to use PMF with SPARSEX(Y) flag instead it.&lt;br /&gt;
&lt;br /&gt;
== Advapix specific data files ==&lt;br /&gt;
New data formats were created for early AdvaPIX variants based on special requirements, but their use was minimal. This chapter serves mainly in case you have such data from the past and need to process it with your software.&lt;br /&gt;
&lt;br /&gt;
=== BMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
This special file contains a &#039;&#039;&#039;binary matrix data from fast measurements&#039;&#039;&#039; (AdvaPIX-Tpx and ModuPIX devices).&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format for obsolete devices&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! BMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
To save theese files the Advapix-Timepix must be used, set the fast mode by setting acq. time 0.01 sec or shorter and frames count divisible by 100.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The file starts with 13 bytes long header and then is followed by pixel values of each frame. Each frame has a few dummy bytes at the beginning. So the layout of the file is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[HEADER][Frame 1][Frame 2][Frame 3] ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where header is 13 bytes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 width;&lt;br /&gt;
u32 height;&lt;br /&gt;
u32 offset;&lt;br /&gt;
char frameType;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;witdh&#039;&#039;&#039; and &#039;&#039;&#039;height&#039;&#039;&#039; is the dimensions of each frame.&lt;br /&gt;
* Each frame data is prepended by &#039;&#039;&#039;offset&#039;&#039;&#039; number of dummy bytes.&lt;br /&gt;
* The &#039;&#039;&#039;frameType&#039;&#039;&#039; specifies the type (variable type) of pixel values. It can be one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
CHAR = 0 (1 byte size)&lt;br /&gt;
BYTE = 1 (1 byte size) &lt;br /&gt;
I16 = 2 (2 bytes size)&lt;br /&gt;
U16 = 3 (2 bytes size)&lt;br /&gt;
I32 = 4 (4 bytes size) &lt;br /&gt;
U32 = 5 (4 bytes size)&lt;br /&gt;
I64 = 6 (8 bytes size)&lt;br /&gt;
U64 = 7 (8 bytes size)&lt;br /&gt;
FLOAT = 8 (4 bytes size)&lt;br /&gt;
DOUBLE = 9 (8 bytes size)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== AMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039;, special, rare format.&lt;br /&gt;
: This is the output of a mechanical &#039;&#039;&#039;assembly of four AdvaPIX-TPX&#039;&#039;&#039; devices, with &#039;&#039;&#039;four USB cables&#039;&#039;&#039;, which was then presented as the AdvaPIX TPX Quad. Not to be confused with the current AdvaPIX-Quad which has a single USB cable.&lt;br /&gt;
: Even if you have this set, don&#039;t save AMF unless you have a very special reason.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! AMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The amf is a binary file that contains data from all the devices combined into one stream of frame matrixes. The file consists of two parts a header (1000 bytes) and the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two versions of the file. Version 1 and Version 2. Version 1 has only one offset parameter, but had a bug, where frames were shifted in the file by 8 bytes. Version 2 has to frame data offsets - before frame data and after frame data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 1):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 1&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offset; // offset of each frame data in the frame block&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 2):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 2&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offsetBefore; // offset of the beginning of frame data in frame block&lt;br /&gt;
 u32 offsetAfter; // offset after frame data&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file may contain variable number of chips (not only data from AdvaPIX Quad = 4 chips).&lt;br /&gt;
* &#039;&#039;&#039;channelCount&#039;&#039;&#039; - How many chip are present in the file.&lt;br /&gt;
* &#039;&#039;&#039;chipsWidth&#039;&#039;&#039; and &#039;&#039;&#039;chipsHeight&#039;&#039;&#039; - How many chips are in x and y coordinate. For example for AdvaPIX Quad it is 2 by 2 (chipsWith = 2, chipsHeight = 2).&lt;br /&gt;
* &#039;&#039;&#039;chipLayout&#039;&#039;&#039; and &#039;&#039;&#039;chipAngles&#039;&#039;&#039; - When the device is read the order of chips is different than shown on the screen (depending on the layout of the internal chip interconnection). Therefore it is necessary to know AdvaPIX QUAD Multi-Frame Format (*.amf) order of the chips and they rotation to create correct image. chipLayout specifies order of the chip (the indexes starts from 0 to the index of last chip, from the top left to the right bottom). The chipAngles specifies rotation of each chip (0 = no rotation, 1 = 90 deg, 2 = 180, 3 = 270, all clockwise).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After the header file the frame data folows. The frame data are saved in frames blocks. Each block contain frames from each detector.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [FrameBlock1][FrameBlock2][FrameBlock3]...&lt;br /&gt;
Frame Block contains:&lt;br /&gt;
 [FrameData1][FrameData2][FrameData3][FrameData4]....&lt;br /&gt;
Each frame contains:&lt;br /&gt;
 [Offset][MatrixData(65536*2)] // Version 1 of the file&lt;br /&gt;
 [OffsetBefore][MatrixData(65536*2)][OffsetAfter] // Version 2 of the file&lt;br /&gt;
Each frame is prepended by an offset (specified in header, offsetBefore) and appended byt some dummy data of length offsetAfter. The frame pixels are saved as 16 bit unsigned integer. Each chip has 256x256 pixels. Therefore - 65536 * 2 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bug in Version 1 of the AMF File:&#039;&#039;&#039;&lt;br /&gt;
The version 1.0 of the AMF file contains bug, where the first frame in the data is missing first 8 bytes. To compensate in the code, when reading make the length of HEADER smaller by 8 bytes =&amp;gt; 992 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
Version 2 has size of offset before and after frame data instead.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offset;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = (HEADER_SIZE - 8) + offset&lt;br /&gt;
secondFrameDataPosition = (HEADER_SIZE - 8) + offset + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offsetBefore + offsetAfter;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = HEADER_SIZE + offsetBefore&lt;br /&gt;
secondFrameDataPosition = HEADER_SIZE + offsetBefore + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MCF and BPC ==&lt;br /&gt;
Old configuration formats. Was used for pixcfg or DACs. Use only to read old data. If it possible, save all old configurations in newer formats, such as XML, and do not use old files due to possible end of support.&lt;br /&gt;
&lt;br /&gt;
= Other files =&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_configuration_ini_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device configuration ini files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_firmware_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device firmware files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: &#039;&#039;&#039;BSTG files&#039;&#039;&#039;]] or see the &#039;&#039;&#039;Spectraimg and data files&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;User XML settings&#039;&#039;&#039;: See: The &#039;&#039;&#039;ISetting object&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;ASCII vertical *.vtxt&#039;&#039;&#039;: CSV-like file used in [[PIXet EDU|&#039;&#039;&#039;PIXet EDU&#039;&#039;&#039;]] and [[PIXet#Clustering_plugin|&#039;&#039;&#039;Clustering plugin&#039;&#039;&#039;]] for saving histograms&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Files and directories of the Pixet and SDK]]&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1708</id>
		<title>File types</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1708"/>
		<updated>2026-04-09T11:03:58Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* HDF5 files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Summary =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ General image/data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII frame&#039;&#039;&#039;. Text files with img lines converted to text lines with numbers separated by spaces.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pbf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet binary frame&#039;&#039;&#039;. Simple binary files, numbers only.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pmf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet multi frame&#039;&#039;&#039;. Default is same as the txt, but multiple frames on top of each other. Can use BINARY flag.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3pa&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels ASCII&#039;&#039;&#039;. Text, CSV-like format, tab-separated columns with the header in the first row. Biggest to saving.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3p&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels&#039;&#039;&#039;. Binary format. Lower saved size than T3PA, contains simple repeats of 1 structure.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3r&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 raw&#039;&#039;&#039;. Complete data stream of Tpx3 chips. Lahge to saving, difficult to understand, slow to processing and can cause processing errors.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;png&#039;&#039;&#039; || Lossless compressed image. Easy to view, but not good for data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;tiff&#039;&#039;&#039; || &#039;&#039;&#039;TIFF, TIF&#039;&#039;&#039;, high bit-depth file usable in common graphic softwares or data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;h5&#039;&#039;&#039; || &#039;&#039;&#039;HDF5&#039;&#039;&#039;, hierarchical data format 5. Used as one of multi-frame formats.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Files auxilliary for image/data&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;dsc&#039;&#039;&#039; || Text metadata list saved beside a standard multiframe files (PMF for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;info&#039;&#039;&#039; || Text metadata list saved beside other than standard multiframe files (T3PA for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;idx&#039;&#039;&#039; || Binary index for multi-frame files. Two formats existing.&amp;lt;br&amp;gt;&lt;br /&gt;
Usesfull for fast access to n-th frame of large text files, necessary for frame seeking in binary sparse files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Special data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;clog, plog&#039;&#039;&#039; || &#039;&#039;&#039;Clusters/pixels logs&#039;&#039;&#039;. Text files contains clusters separated to frames with pixels lists. Historic formats for saving a data with few hited pixels in a frames. (&#039;&#039;&#039;obsolette&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bstg&#039;&#039;&#039; || &#039;&#039;&#039;Binary settings&#039;&#039;&#039; file. Measured or processed data with all configuration.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: BSTG files]] or see the &amp;quot;Spectraimg and data files&amp;quot; chapter in the Python API manual.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;vtxt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII vertical&#039;&#039;&#039; CSV-like file used in PIXet EDU and Clustering plugin for saving histograms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Configuration files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;xml&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ini&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
: &#039;&#039;&#039;Note&#039;&#039;&#039; Since 2025/09 release &#039;&#039;&#039;format changed&#039;&#039;&#039; to fully standard ini&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;txt&#039;&#039;&#039; ||&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;mcf&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
# DAC settings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bpc&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File type and extensions constants =&lt;br /&gt;
There are constants for file types and extensions. It can be used with [[Python API | &#039;&#039;&#039;Python API&#039;&#039;&#039;]] for filenames testing or with acquisition functions. But &#039;&#039;&#039;mostly PX_FTYPE_AUTODETECT will be enough&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Python example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Python&amp;gt;&lt;br /&gt;
# measure and save one 0.25 second frame to png file named &amp;quot;testFile.png&amp;quot;&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_PNG, &amp;quot;testFile&amp;quot;)&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_AUTODETECT, &amp;quot;testFile.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! colspan=3 | File types and extensions constants table &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! File type constants !! File extensions constants !! Ext value&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_NONE || (No direct file saving – data stored only in memory) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_AUTODETECT || (FTYPE detected by extension in a filename) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_ASCII_FRAME || PX_EXT_ASCII_FRAME || &amp;quot;txt&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_FRAME || PX_EXT_BINARY_FRAME || &amp;quot;pbf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_MULTI_FRAME || PX_EXT_MULTI_FRAME || &amp;quot;pmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_MULTIFRAME || PX_EXT_BINARY_MULTI_FRAME || &amp;quot;bmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS || PX_EXT_TPX3_PIXELS || &amp;quot;t3p&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS_ASCII ||PX_EXT_TPX3_PIXELS_ASCII || &amp;quot;t3pa&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_CLUSTER_LOG || PX_EXT_CLUSTER_LOG || &amp;quot;clog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXEL_LOG || PX_EXT_PIXEL_LOG || &amp;quot;plog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PNG || PX_EXT_PNG || &amp;quot;png&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_RAW_DATA || PX_EXT_TPX3_RAW_DATA || &amp;quot;t3r&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXET_RAW_DATA || PX_EXT_PIXET_RAW_DATA || &amp;quot;prd&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_EXTERNAL || (reserved) ||&lt;br /&gt;
|-&lt;br /&gt;
| (description file saved automatically with pmf/txt) || PX_EXT_FRAME_DESC || &amp;quot;dsc&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| (index file saved automatically with pmf/txt) || PX_EXT_INDEX || &amp;quot;idx&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File saving flags summary =&lt;br /&gt;
File saving flags can do additional settings for file(s) saving.&lt;br /&gt;
* Can be used in &#039;&#039;&#039;saving&#039;&#039;&#039; files or in &#039;&#039;&#039;doAdvancedAcquisition&#039;&#039;&#039; python methods, for example.&lt;br /&gt;
* Flags can be combined.&lt;br /&gt;
* Default frame file settings is set of separate subframes text files, with all pixels include zeros, each subframe with idx+dsc files:&lt;br /&gt;
:: file_ToT.pmf, file_ToT.pmf.dsc, file_ToT.pmf.idx, file_ToA.pmf, file_ToA.pmf.dsc, file_ToA.pmf.idx&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ File saving flags&lt;br /&gt;
|-&lt;br /&gt;
! Flag constant base name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_BINARY || Use binary format in pmf.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEX || Index + non-zero pixels in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEXY || X, Y + non-zero pixel in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NODSC || Do not add dsc file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NOSUBFRAMES || Do not use subframes, save main frame only.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_ONEFILE || Save all subframes to a single file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME || Save separate all subframes and main frame extra.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The file saving flags can be used in&lt;br /&gt;
* &#039;&#039;&#039;Python API&#039;&#039;&#039;: Use pixet.PX_FRAMESAVE_... constants in flags parameter of some measuring/saving methods.&lt;br /&gt;
* &#039;&#039;&#039;Binary API&#039;&#039;&#039;: Use PX_FRAMESAVE_... constants in flags parameter of some measuring functions.&lt;br /&gt;
* The Pixet program. Available in the &#039;&#039;&#039;More measurement settings, after compatible filename was selected&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:File-flags-dialog.png|frame|alt=File saving flags in More measurement settings in Pixet|File saving flags in More measurement settings in Pixet]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File extensions and flags: TXT/PBF/PMF details =&lt;br /&gt;
&lt;br /&gt;
== The files formats ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;width:50px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Text&#039;&#039;&#039; || Single frame in the text file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pbf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Binary&amp;amp;nbsp;Frame&#039;&#039;&#039; || Single frame in the binary file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pmf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Multi&amp;amp;nbsp;Frame&#039;&#039;&#039; || Multiframe file with text or binary format, depends on flags used with saving.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;idx&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Index&#039;&#039;&#039; || Binary array of structs with 64b pointers to start of frames, frame metadata and subframes.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;dsc&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Description&#039;&#039;&#039; || List of all metadata for each frame and subframe. Actual device and acquisition parameters, data types, etc. The &amp;quot;Frame name&amp;quot; item can be helpful to orientation in pmf structure if the ONEFILE flag used. The Type=item is helpful to understanding the structure of data if the BINARY flag used.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi-files names generation ==&lt;br /&gt;
; Note:&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; flags 0 (default), input filename = &amp;quot;name&amp;quot;, acqCount = 1&lt;br /&gt;
: name_ToA.txt, name_ToA.txt.dsc, name_ToT.txt, name_ToT.txt.dsc&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; acqCount = 6:&lt;br /&gt;
: name_0_ToA.txt, name_0_ToA.txt.dsc, name_0_ToT.txt, ...&lt;br /&gt;
: ...&lt;br /&gt;
: name_5_ToA.txt, name_5_ToA.txt.dsc, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PMF note&lt;br /&gt;
: With each pmf generating &#039;&#039;&#039;.pmf.idx&#039;&#039;&#039; binary file, other is same as TXT with acqCount = 1.&lt;br /&gt;
&lt;br /&gt;
== Files with flags=0 ==&lt;br /&gt;
; Note&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; TXT file data, default&lt;br /&gt;
: 0 0 0 5 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0 872 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: (256 lines)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PBF file data, default&lt;br /&gt;
: Simple pixels binary data without anything else&lt;br /&gt;
: Data can be typically 16 or 32 bit raw integers with little-endian order and doubles for calibrated data.&lt;br /&gt;
: For example, MiniPIX has single chip, this has 65536 pixels, it&#039;s binary file has 65536 words (size 128 kB binary), sometimes 65536 doubles (size 512 kB binary).&lt;br /&gt;
: The &#039;&#039;&#039;data format&#039;&#039;&#039; can be read in the line starting with Type= line in the [[#DSC files details | &#039;&#039;&#039;DSC file&#039;&#039;&#039;]] saved beside the data file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PMF file data, default&lt;br /&gt;
: 0.00000 78.65742 0.00000 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0.00000 0.00000 999785.5 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter &lt;br /&gt;
: (256 lines * acqCount)&lt;br /&gt;
&lt;br /&gt;
== Flags influence to files ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEX flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| _ToA.txt file !!colspan=&amp;quot;2&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 227212.500000 || 0 || 20&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 310685.937500 || 17 || 13&lt;br /&gt;
|-&lt;br /&gt;
| 255 || 265487.500000 || 255 || 11&lt;br /&gt;
|-&lt;br /&gt;
| 1274 || 105728.125000 || 1274 || 9&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;4&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEXY flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;3&amp;quot;| _ToA.txt file !!colspan=&amp;quot;3&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 247 || 3 || 189851.562500 || 247 || 3 || 16&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 4 || 140042.187500 || 250 || 4 || 12&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 9 || 317195.312500 || 5 || 9 || 5&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;6&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;6&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;PMF file data, pixet.PX_FRAMESAVE_SPARSEX(Y) flag&#039;&#039;&#039;&amp;lt;br&amp;gt;Same as TXT, but containing single lines with only # to separate frames&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! X !! Y !! ToA !! Line description&lt;br /&gt;
|-&lt;br /&gt;
| 232 || 139 || 321620.312500 || frame 1, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 252 || 340231.250000 || frame 1, px 2&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;3&amp;quot;| # || frames separator&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 0 || 258270.312500 || frame 2, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 201 || 0 || 76593.750000 || frame 2, px 2&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 1 || 268642.187500 || frame 2, px 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_ONEFILE&lt;br /&gt;
: All the data is in one file, subframes are placed one behind the other. If the measurement result has 10 frames with 2 subframes A/B, each _n TXT file contains 2 subrfames and the PMF contains 20 frames in order:&lt;br /&gt;
: sfr0A, sfr0B, sfr1A, sfr1B, ...&lt;br /&gt;
: The exact order and names of type of (sub)frames is listed in the DSC file. The DSC have separate records [Fn] for all the items.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME&lt;br /&gt;
: The group of the saved files contains the main frame and all subframes. Subframe files end in _sfrName, the main frame does not. In DSC file accompanying the TXT with main frame is not the &amp;quot;Frame name&amp;quot; item.&lt;br /&gt;
: Not applicable if combined with the &#039;&#039;&#039;ONEFILE&#039;&#039;&#039; flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_BINARY&lt;br /&gt;
: If the file type supports text and binary format, ex. PMF, save the binary.&lt;br /&gt;
: Not applicable to TXT, must use PBF instead.&lt;br /&gt;
: Data in the file are the simple array of non-calibrated 16 or 32b integers or calibrated doubles. See the DSC file for used data type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BINARY + SPARSEXY examples:&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
[[File:File-binary-sparsexy-example.png|frame|none|alt=Example of data saved if flags BINARY+SPARSEXY used|Example of data saved if flags BINARY+SPARSEXY used]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Timepix3 specific data files =&lt;br /&gt;
The Timepix3 have the data-driven mode feature. It is &amp;quot;frameless&amp;quot; mode, where the device can continuously send the data of the pixels just hit indefinitely. Each sent pixel contains information:&lt;br /&gt;
# Pixel position index&lt;br /&gt;
# Event registration time (raw ToA count and FToA, conversion and corrections needed)&lt;br /&gt;
# Energy deposited in a pixel (raw ToT count, need conversion using the chip-specific calibration table containing cal. constants for each pixel)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Theese files can be very large. You can collecting a data from cosmic particles using Minipix continuously for more weeks and get a T3PA sized in tens of megabytes. But if some noising pixel occurs, a files can has many gygabytes per day. If the Advapix used with x-ray mashines or accelerators, the output data can has gigabytes in an instant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The formats:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;T3PA&#039;&#039;&#039; files are &#039;&#039;&#039;text/csv&#039;&#039;&#039; files with basic data. User can simply see it in text editor and process it in Python etc.&lt;br /&gt;
* &#039;&#039;&#039;T3P&#039;&#039;&#039; files are &#039;&#039;&#039;binary&#039;&#039;&#039; files with basic data same as T3PA. Faster saving, shorter files.&lt;br /&gt;
* &#039;&#039;&#039;T3R&#039;&#039;&#039; files are binary files with complete raw communication data. &#039;&#039;&#039;For special purposes only.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data order&#039;&#039;&#039;&lt;br /&gt;
* The order of the data roughly corresponds to the order of events, so data an hour later will definitely be further in the file.&lt;br /&gt;
* But the exact order corresponds to the order in which the data came from the device, so for example a later event that occurred at the edge where the chip is read can be recorded earlier than an earlier event that occurred further from the edge.&lt;br /&gt;
* The unevenness of the order occurs from tens of ns on a lightly loaded Advapix to several ms with a heavy load on the Minipix.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;How to get the files:&#039;&#039;&#039;&lt;br /&gt;
* In the [[PIXet|&#039;&#039;&#039;Pixet&#039;&#039;&#039;]] program set operation mode to ToA+ToT and use the &amp;quot;Pixels&amp;quot; measurement type and turn on file saving.&lt;br /&gt;
* In the [[Binary_core_API|&#039;&#039;&#039;binary API&#039;&#039;&#039;]] using programs set operation mode to PXC_TPX3_OPM_TOATOT and use the [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]] function.&lt;br /&gt;
* In the [[Python API|&#039;&#039;&#039;Python API&#039;&#039;&#039;]] using programs set operation mode to pixet.PX_TPX3_OPM_TOATOT and use the dev.&#039;&#039;&#039;doAdvancedAcqquisition&#039;&#039;&#039; with acqType=pixet.PX_ACQTYPE_DATADRIVEN.&lt;br /&gt;
&lt;br /&gt;
== T3PA files details ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 pixels ASCII file&#039;&#039;&#039; is timepix3 data file in text format with lines and tabs. Can be read as CSV, but its size is not limited to sizes readable by Office-like programs . Contains the header line and data lines with record index, pixel index in the matrix, Time of arrival, Time over threshold, Fine ToA and Overflow.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The T3PA example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Index   Matrix Index    ToA     ToT     FToA    Overflow&lt;br /&gt;
0       1028    1918    14      22      0&lt;br /&gt;
1       1028    3126    8       28      0&lt;br /&gt;
2       1028    3778    5       23      0&lt;br /&gt;
...&lt;br /&gt;
156003  39793   98473646054     38      9       0&lt;br /&gt;
156004  190     98492090610     19      3       0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Index&#039;&#039;&#039; is simple index of measurement line. This growing while measurement is running. If you append new measurement to existing file, new index is 0 again and again growing while new measurement is running.&lt;br /&gt;
[[File:Minipix-pixel00.png|frame|right|alt=Physical position of the x=0, y=0 pixel on the Minipix|Physical position of the x=0, y=0 pixel on the Minipix]]&lt;br /&gt;
* The &#039;&#039;&#039;Matrix Index&#039;&#039;&#039; is index of the pixel. On the Minipix Tpx3 is 0 at the left-down (see image)&lt;br /&gt;
* The &#039;&#039;&#039;ToA&#039;&#039;&#039; is time of arrival in units 25 ns, mod by limit specific by device type.&lt;br /&gt;
:: For example Minipix 2&amp;lt;sup&amp;gt;64&amp;lt;/sup&amp;gt; (14600y), Advapix-single 2&amp;lt;sup&amp;gt;30&amp;lt;/sup&amp;gt; (26s), Advapix-Quad 2&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (6.5s).&lt;br /&gt;
: &#039;&#039;&#039;Note:&#039;&#039;&#039; The ToA on-chip implementation in the pixels is limited to 14 bits (409.6 µs).&lt;br /&gt;
:: The ToA in T3PA is extended by device. But there is inherent uncertainty around the borders. These values may be incorrectly assigned. Users not comfortable with our extension can apply AND with (uint64)16383 to extended ToA to get original ToA from the chip.&lt;br /&gt;
* The &#039;&#039;&#039;ToT&#039;&#039;&#039; is time over threshold in units 25 ns.&lt;br /&gt;
* The &#039;&#039;&#039;FToA&#039;&#039;&#039; stands for &amp;quot;fine ToA&amp;quot; and it is the finest step of the ToA measurement. To properly account for this step in the conversion of ToA to time, it is necessary to subtract the amount of counts of fToA in the following manner:&lt;br /&gt;
:: &#039;&#039;&#039;Time [ns] = 25*ToA - (25/16)*fToA&#039;&#039;&#039;&lt;br /&gt;
: The original range of this fToA value in the chip is 4 bits, or 16 values. This is extended in the post-processing of the data into 5 bits, or 32 values to include a correction for Intentional phase shift of clocks propagated into the columns of the chip. The final value exported into t3pa files has a range of 5 bits, or 32 values, but the previous equation still stands.&lt;br /&gt;
* The &#039;&#039;&#039;Overflow&#039;&#039;&#039; is sign of data transfer overflow or other special cases.&lt;br /&gt;
:: &#039;&#039;&#039;Note:&#039;&#039;&#039; In data from multichip devices, there is not Overflow, replaced by Chip index (=copy of bits 16+ of Matrix Index. But column name is still Overflow).&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;1 - data transfer overflow&#039;&#039;&#039;:&lt;br /&gt;
::: matrix index = 0x74: start of lost data&lt;br /&gt;
::: matrix index = 0x75: end of lost data, toa is length of the missing time&lt;br /&gt;
::: (this can occurs with rates over megahits per seconds for Minipix)&lt;br /&gt;
::: matrix index = 0: Data corruption event detected - all next data can be corrupted&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;10 - trigger timestamp&#039;&#039;&#039; (If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled):&lt;br /&gt;
::: matrix index = 0, ToT = 0&lt;br /&gt;
::: ToA = Timestamp of arrival external sync pulse to the device.&lt;br /&gt;
::: FToA = Count of expected ToA counter overflows.&lt;br /&gt;
::: If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, every sync pulse cause creating of one line record, independent of sync is or is not used to start of the acquisition. Timestamps can be recorded some time before the measurement starts. They may have zero or, conversely, an arbitrarily high value.&lt;br /&gt;
::: Warnings:&lt;br /&gt;
:::* Be careful about having too high values ​​in the FToA column (increment every 409.6 µs).&lt;br /&gt;
:::* Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&lt;br /&gt;
&lt;br /&gt;
* Related: [[The_RawTpx3Pixel_structure_in_memory#Explanation_of_the_struct|The RawTpx3Pixel structure in memory: Explanation of the struct]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If &#039;&#039;&#039;saving of the T3PA repeated to the same file&#039;&#039;&#039;, new data will be append with new reset of record index and ToA and the file containing parts is like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
507812	353	39993345	1022	15	0&lt;br /&gt;
507813	46177	39999843	159	2	0&lt;br /&gt;
507814	45921	39999843	159	2	0&lt;br /&gt;
0	421	2	13	29	0&lt;br /&gt;
1	297	2	22	27	0&lt;br /&gt;
2	297	145	62	17	0&lt;br /&gt;
3	297	283	19	13	0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3P files details ==&lt;br /&gt;
&#039;&#039;&#039;Timepix3 Binary Pixels&#039;&#039;&#039; is similar to t3pa file without record index. And the numbers are not saved as ASCII, but binary. The file contains one pixel after each other. Each pixel in this format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 matrixIdx;&lt;br /&gt;
u64 toa;&lt;br /&gt;
byte overflow;&lt;br /&gt;
byte ftoa;&lt;br /&gt;
u16 tot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P file contents example:&#039;&#039;&#039;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ As see in a HEX editor&lt;br /&gt;
|- &lt;br /&gt;
| 5E86 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0300&lt;br /&gt;
|-&lt;br /&gt;
| 6087 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 6387 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 001B || 0100&lt;br /&gt;
|-&lt;br /&gt;
| 6486 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 5D84 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0010 || 0200&lt;br /&gt;
|-&lt;br /&gt;
| 89BD || 0000 || 240B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0D00&lt;br /&gt;
|-&lt;br /&gt;
| 5F80 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0002 || 0600&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ Redistributed according the structure&lt;br /&gt;
|-&lt;br /&gt;
! pxIdx&amp;lt;br&amp;gt;4 B !! ToA&amp;lt;br&amp;gt;8 B !! Over&amp;lt;br&amp;gt;1 B !! fToA&amp;lt;br&amp;gt;1 B !! ToT&amp;lt;br&amp;gt;2 B&lt;br /&gt;
|-&lt;br /&gt;
| 5E 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 03 00&lt;br /&gt;
|-&lt;br /&gt;
| 60 87 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 63 87 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 1B || 01 00&lt;br /&gt;
|-&lt;br /&gt;
| 64 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 15 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 5D 84 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 10 || 02 00&lt;br /&gt;
|-&lt;br /&gt;
| 89 BD 00 00 || 24 0B 00 00 00 00 00 00 || 00 || 15 || 0D 00&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Corresponding start of T3PA&lt;br /&gt;
: Index &amp;amp;nbsp;	Matrix Index &amp;amp;nbsp;	ToA &amp;amp;nbsp;	ToT &amp;amp;nbsp;	FToA &amp;amp;nbsp;	Overflow&lt;br /&gt;
: 0  &amp;amp;nbsp; 34398  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 3  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 1  &amp;amp;nbsp; 34656  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 2  &amp;amp;nbsp; 34659  &amp;amp;nbsp; 2847   &amp;amp;nbsp; 1  &amp;amp;nbsp; 27 &amp;amp;nbsp; 0&lt;br /&gt;
: 3  &amp;amp;nbsp; 34404  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 21 &amp;amp;nbsp; 0&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;Overflow value&#039;&#039;&#039; - Data transfer overflow indicator or other special value indicator.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#T3PA files details]] for details and see below for T3P differences in the trgTimeStamp.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P files with trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Note: This is old internal testing feature and was not intended for mormal using. If you do want to use it, here&#039;s some info:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, file can contains lines of tab-divided ASCII numbers. Every record is six numbers divided by tabs (0x09) and ended with line end (0x0A).This is simple T3PA line. See the T3PA with overflow=10 for details.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every sync pulse cause creating of one line record. In the file, each sync record and each pixel are simply stored in the order as it arrived on the computer. Any combination of order and number of binary and text records can be expected.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This is a source of complications when using the file. The file must be browsed sequentially as binary pixels. At the first occurrence of faulty or suspicious values (eg high pixel index, high ToA, Overflow&amp;gt;1) assume that the current record is not a pixel, but that the ASCII/tab line starts here and that it ends at 0A.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3R files ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 Raw Data File&#039;&#039;&#039; is special format for testing purposes. This is a dump of raw communication from the device. The file format is device specific, binary, complex and files are very large. Use this only if you have no other option.&lt;br /&gt;
&lt;br /&gt;
= DSC/INFO metadata files =&lt;br /&gt;
The metadata text files are saved beside the data files and containing informations about device and settings used for measuring the data. It can be usable while openning the data file in the Pixet program or in other working with the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the API is used to saving the data, programmer can use callback like us &amp;quot;&#039;&#039;&#039;before saving data callback&#039;&#039;&#039;&amp;quot; to add Your specific metadata items or can remove items that will not need.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;DSC&#039;&#039;&#039; are files generated beside the frame data and cotaining information for each frame&lt;br /&gt;
* &#039;&#039;&#039;INFO&#039;&#039;&#039; are files generated beside pixel data and some special data formats&lt;br /&gt;
&lt;br /&gt;
== DSC files details ==&lt;br /&gt;
The first line is &#039;&#039;&#039;header line&#039;&#039;&#039;:&lt;br /&gt;
: Some like as &#039;&#039;&#039;A123456789&#039;&#039;&#039;: B=binary / A=ASCII and number = count of frames in multiframe data file&lt;br /&gt;
Next are &#039;&#039;&#039;frames&#039;&#039;&#039; in format:&lt;br /&gt;
: &#039;&#039;&#039;1. [Fn]&#039;&#039;&#039; - Frame with idx n start: [F0], [F1], ...&lt;br /&gt;
: &#039;&#039;&#039;2. Frame type&#039;&#039;&#039; - Data type, pixel format and frame size: Some like as &amp;quot;Type=i16 [X,C] width=256 height=256&amp;quot;&lt;br /&gt;
:: Pixels format options:&lt;br /&gt;
::: &#039;&#039;&#039;matrix&#039;&#039;&#039; - Whole matrix saved. Number of saved pixels are allways width*height.&lt;br /&gt;
:::: Multiframe data file not contains frame separator.&lt;br /&gt;
::: &#039;&#039;&#039;[X,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has matrix index and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
::: &#039;&#039;&#039;[X,Y,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has X,Y position and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
: &#039;&#039;&#039;3. Frame metadata&#039;&#039;&#039; - List of metadata items separated by blank lines:&lt;br /&gt;
::: Each metadata item is line triplet:&lt;br /&gt;
:# &amp;quot;Item name&amp;quot; (&amp;quot;Item description&amp;quot;): Example: &amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
:# DataType[valCount] Example: double[1]&lt;br /&gt;
:# Values list Example: 0.500000&lt;br /&gt;
:# (blank line)&lt;br /&gt;
: &#039;&#039;&#039;4. (blank line)&#039;&#039;&#039; - end of frame (there are two blank lines, the last metadata item end and the frame end)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In &#039;&#039;&#039;txt.dsc&#039;&#039;&#039; and &#039;&#039;&#039;pbf.dsc&#039;&#039;&#039;, end of the frame is end of the file.&amp;lt;br&amp;gt;&lt;br /&gt;
In the &#039;&#039;&#039;pmf.dsc&#039;&#039;&#039;, next frames or subframes metadata follows.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Some example (PBF 1 frame, with BINARY and SPARSEXY – test_49_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001                                      B=binary / A=ASCII and number = count of frames in multiframe file&lt;br /&gt;
[F0]                                            Index of frame in the file = 0&lt;br /&gt;
Type=double [X,Y,C] width=256 height=256        Data type double, X,Y,C = only hit pixels saved and has XY pos.&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):  Some metadata item name and (description)&lt;br /&gt;
u32[1]                                          Type of the item data [number of values]&lt;br /&gt;
49                                              The value&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA                                             This is the ToA frame&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
(end of the file)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Other example (PMF 10 frames, with BINARY+SPARSEX+ONEFILE – test.pmf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000010&lt;br /&gt;
[F0]                                            Start of the first subframe&lt;br /&gt;
Type=double [X,C] width=256 height=256          Pixel index and double type pixel data (ToA in ns)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA &lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[F1]                                            Start of the second subframe&lt;br /&gt;
Type=i16 [X,C] width=256 height=256             Pixel index and i16 type pixel data (ToT in ticks 40MHz)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
(and the ToT frame metadata, [F2] and ToA subframe, [F3] and ToT sfr, … [Fn] and ToT sfr of (n/2)th frame)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Complete one frame DSC example (PMF 1 frame, BINARY+SPARSEX – test_15_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001&lt;br /&gt;
[F0]&lt;br /&gt;
Type=double [X,C] width=256 height=256&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
15&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059034.903085 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
0.500000&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
I08-W0060&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1301 501 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-500 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.7.8&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059042.934810 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Thu Dec 9 15:10:42.934809 2021&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.026744&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== INFO files details ==&lt;br /&gt;
* The T3PA.INFO containing metadata in format very similar to one frame of DSC file.&lt;br /&gt;
* Some other INFO files can containing simpliest formated metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;T3PA.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[FileInfo]&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.719000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1.000000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
D06-W0065&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1237 437 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-450 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.8.1&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Shutter open time&amp;quot; (&amp;quot;Shutter open timestamp&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Tue Jan  9 15:12:18.867000 2024&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.015797 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;BMF.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[File Meta Data]&lt;br /&gt;
Acq Serie Index:0&lt;br /&gt;
Acq Serie Start time:1704813831.469&lt;br /&gt;
Acq time:0.001&lt;br /&gt;
ChipboardID:G03-W0259&lt;br /&gt;
DACs:10 100 255 127 127 0 153 6 130 100 80 85 128 128&lt;br /&gt;
HV:-450&lt;br /&gt;
Interface:AdvaPIX&lt;br /&gt;
Mpx type:2&lt;br /&gt;
Pixet version:1.8.1&lt;br /&gt;
Start time:1704813831.633&lt;br /&gt;
Start time (string):Tue Jan  9 16:23:51.633000 2024&lt;br /&gt;
Threshold:5.02649397407217&lt;br /&gt;
Timepix clock:50&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= IDX files details =&lt;br /&gt;
The IDX files are generated with multiframe files to help with fast seeking frames in files. &#039;&#039;&#039;Each frame except first&#039;&#039;&#039; has the basic structure in the IDX file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct IndexItem {&lt;br /&gt;
 i64 dscPos;    // frame position in the DSC file&lt;br /&gt;
 i64 dataPos;   // frame position in the main data file&lt;br /&gt;
 i64 sfPos;     // subframe position if exist subframes file next to the main data file (usually not and =0)&lt;br /&gt;
};&lt;br /&gt;
// Note: CLOG.IDX has no this structure, this in only i64 pointers to frames&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;PMF.IDX&#039;&#039;&#039; files generated beside the PMFs. Contains the simple binary array of structs of 3 little-endian qwords with addresses associated to the start of each frame except first: DSC, frame and subframe.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
; .pmf.idx with BINARY+ONEFILE, ToA+ToT example&lt;br /&gt;
: main data contains&lt;br /&gt;
:* ToA subframes (double*0x10000 = len 0x80000)&lt;br /&gt;
:* ToT subframes (i16*0x10000 = len 0x20000)&lt;br /&gt;
The IDX contains&lt;br /&gt;
# Pointers to frames in DSC file at 0 (not in idx), 0x03B5, 0x075D, 0x0B08, 0x0BE0, ... (points to an empty line before [Fx] line)&lt;br /&gt;
# Pointers to frames in main data file at 0 (not in idx), 0x080000, 0x0A0000, 0x120000, 0x140000, 0x1C0000, ...&lt;br /&gt;
# Pointers to frames in additional subframes file (not exist -&amp;gt; all=0)&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-pmf-idx-example.png|frame|right|alt=.pmf.idx file example|.pmf.idx file example]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= HDF5 files =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The HDF5 (&#039;&#039;&#039;.H5&#039;&#039;&#039;) files are general standard binary containers for structured data. If used to save, contains both measured data and metadata.&lt;br /&gt;
* To access theese files, use third party tools like as:&lt;br /&gt;
:* &#039;&#039;&#039;HDFview&#039;&#039;&#039; from HDF Group&lt;br /&gt;
:* &#039;&#039;&#039;h5py&#039;&#039;&#039; python library from HDF Group&lt;br /&gt;
:: See: [[Python_API#Examples|&#039;&#039;&#039;Python API: Examples&#039;&#039;&#039;]] for reading using Python&lt;br /&gt;
:* &#039;&#039;&#039;HDF5 C++ API&#039;&#039;&#039; from HDF Group&lt;br /&gt;
* If you are saving from the API without Pixet, the &#039;&#039;&#039;hdf5io.dll&#039;&#039;&#039; plugin must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the hdf5io plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| The plugin file must exist in the directory.&lt;br /&gt;
| [[File:Plugin-hdf5.png|thumb|alt=HDF5 plugin file in plugins directory|HDF5 plugin file in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Saving a HDF5 files ==&lt;br /&gt;
* The files can be saved from the Pixet program or by API.&lt;br /&gt;
: [[File:Files-hdf5-saving-pixet.png|frame|none|alt=Saving HDF5 from the Pixet program|Saving HDF5 from the Pixet program:&amp;lt;br&amp;gt;First was saved the &#039;&#039;&#039;test.h5&#039;&#039;&#039;, second the &#039;&#039;&#039;test.h5:meas2&#039;&#039;&#039;]]&lt;br /&gt;
* When saving to an existing file, the data is added to the existing structure in it.&lt;br /&gt;
* Use the AUTODETECT filetype in the API functions using filetype.&lt;br /&gt;
* Saving flags will be ignored.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Next image showing 3 files in the HDFview program&lt;br /&gt;
# File test1.h5 saved by acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
# File test2.h5 saved by tripple acquisitions of 10 frames, with filename settings &amp;quot;test1.h5:set0&amp;quot;,  &amp;quot;test1.h5:set1&amp;quot; and  &amp;quot;test1.h5:set2&amp;quot;.&lt;br /&gt;
# File test1.h5, existing from first acq., saved again in next acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-hdf5-examples.png|frame|none|alt=HDF5 files examples in HDFview|HDF5 files examples in HDFview: Single acq. with 10 frames, triple with structure, first file after second acq.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The files was saved from the PY script:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=Python start=60&amp;gt;&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set0&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set1&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set2&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pixet structures in HDF5 ==&lt;br /&gt;
As see at the &amp;quot;HDF5 files examples&amp;quot; image in the previous chapter, the acquisition creates the file with structure (or adds to existing):&lt;br /&gt;
# Root name or path if defined by adding :hdfpath at end of filename (optional)&lt;br /&gt;
# Frame list: Frame_0, Frame_1, ...&lt;br /&gt;
# Main frame data: The Data item&lt;br /&gt;
# Basic informations items: AcqTime, Width, Height, StartTime&lt;br /&gt;
# MetaData directory containing same data as saved to the dsc files alongise classic simple data files.&lt;br /&gt;
# SubFrames directory with subframes subdirs named by subframe names (ToA, ToT, Event, iToT, ...) containing same structures as the main frame.&lt;br /&gt;
&lt;br /&gt;
= TIFF images =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The TIFF (&#039;&#039;&#039;.TIFF / .TIF&#039;&#039;&#039;) &amp;quot;Tag Image File Format&amp;quot;, files are image format for high-resolution and high-bitDepth data and has multi-page support. If used to save, contains measured data in 32 bit integer format.&lt;br /&gt;
* If saving from API without the Pixet program, the &#039;&#039;&#039;tiffio.dll plugin&#039;&#039;&#039; must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]* Note: Multipage format is not yet supported in Pixet. &lt;br /&gt;
* To simplify further data processing, Pixet saving an integer data only in 32bit format without any conversion. Or if data is double/float, the conversion factor is used (change it in the File output tab on Measurement settings dialog).&lt;br /&gt;
* To facilitate processing, an &#039;&#039;&#039;auxiliary file .tiff.aux.xml&#039;&#039;&#039; is also saved with the image. Note: Contents are completelly different from DSC/INFO files.&lt;br /&gt;
* It very often happens that integer data has negligible values ​​against the range of 32 bits (over 4 billion). This can cause the image &#039;&#039;&#039;looks like completely black&#039;&#039;&#039; when viewed in some programs, even though it contains data.&lt;br /&gt;
* The image can be shown in the Pixet. Drag-drop the image to the image zone. Recommended view settings: Auto range / Smart&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the tiffio plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|[[File:Plugin-tiff.png|thumb|alt=TIFF plugin files in plugins directory|TIFF plugin files in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Configuration files =&lt;br /&gt;
Ecosystem of the Pixet software containing many configuration files and formats. Part of this was inherited from the old Pixelman program. Do not use formats marked OBSOLETE to save new data. Load old data and save it to new formats before support ends.&lt;br /&gt;
&lt;br /&gt;
== Calibration files ==&lt;br /&gt;
# Threshold DAC/energy curves of every pixel are different. For proper device function the threshold adjustment matrix needed. This data is part of the pixel matrix configuration and it is part of the device XML config file.&lt;br /&gt;
# If the readout chip supports energy measuremnts, You need calibration data for convert digital data to the energy in keVs. Every pixel has own calibration coeficients. It&#039;s values depends on sensor chip local differences.&lt;br /&gt;
::* Calibration in the device config file - simpliest variant. The device config file contains calibration section with encoded binary data.&lt;br /&gt;
::* Set of the calibration files - files named name_a.txt, name_b.txt, name_c.txt and name_t.txt. Data is in the text matrix like in the frame files.&lt;br /&gt;
::* Most functions support using filename &amp;quot;name.xml&amp;quot; or &amp;quot;name_a.txt|name_b.txt|name_c.txt|name_t.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix configuration files ==&lt;br /&gt;
Contains matrix of:&lt;br /&gt;
# threshold adjustment bits of the pixel&lt;br /&gt;
# if the pixel is masked&lt;br /&gt;
# if test is on&lt;br /&gt;
# other bits depending on the chip type&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Overview&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;nbsp;&#039;&#039;&#039;bpc&#039;&#039;&#039;&amp;amp;nbsp;&lt;br /&gt;
|| &#039;&#039;&#039;Binary Pixel Configuration&#039;&#039;&#039; || All PM config in one file, meaning of the bits depends on the chip.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Mask Matrix&#039;&#039;&#039; || Text file with pixel mask&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Test Bit Matrix&#039;&#039;&#039; || Text file with test bits&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii THL adj. bits Matrix&#039;&#039;&#039; || Text file with threshold values adjustment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== XML format ==&lt;br /&gt;
Standard XML files&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== INI format ==&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: The original implementation in Pixet environment &#039;&#039;&#039;was non-standard&#039;&#039;&#039;. Older files have sections, such as [hwlibs], which contain values ​​themselves without name= beginnings.&lt;br /&gt;
: Starting &#039;&#039;&#039;from 2025/09 we are switching to standard INI&#039;&#039;&#039;. In sections where previously item beginnings were missing, we have switched to named items, where the name does not matter.&lt;br /&gt;
&lt;br /&gt;
== TXT format ==&lt;br /&gt;
All except DAC settings is simple matrix with lines containing numbers separated by spaces.&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Obsolete files =&lt;br /&gt;
All formats in this chapter are obsolete and, with the exception of CLOG, has not used for long time and it is possible that their support will be removed.&lt;br /&gt;
Pay attention to possible ambiguities when using CLOG.&lt;br /&gt;
&lt;br /&gt;
== CLOG and PLOG files ==&lt;br /&gt;
Old text formats from age of the first Timepix chips. Due to the new use with Tpx3, new ambiguities in CLOG have arisen.&lt;br /&gt;
* &#039;&#039;&#039;CLOG&#039;&#039;&#039; (clusters log) has remained popular in the context of cluster processing.&lt;br /&gt;
* &#039;&#039;&#039;PLOG&#039;&#039;&#039; (pixels log) is currently no longer used.&lt;br /&gt;
&lt;br /&gt;
=== CLOG and CLOG.IDX files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
The CLOG format was developed to facilitate further processing of cluster data by the user programs. This is a text file divided to the frame records and the records can contain a clusters. Frames and clusters are separated by the line breaks. Frames can be separated by whole free line.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The record format&lt;br /&gt;
: Frame FN (frameStart, frameAcqTime s)&lt;br /&gt;
: [x, y, energy, ToA] [x, y, energy, ToA] [x, y, energy, ToA] ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;FN&#039;&#039;&#039; || Frame index number. First 0 or 1.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameStart&#039;&#039;&#039; || Start time of the frame. There are variants:&lt;br /&gt;
1. If it from measuring or from replay frame-based data with metadata available:&lt;br /&gt;
: Linux format, frame starting time from PC’s getPrecisionTime.&lt;br /&gt;
2. If it from pixel-based data with metadata available (file.t3pa + file.t3pa.info):&lt;br /&gt;
: Linux format, acq. starting time from PC’s getPrecisionTime with added time from data.&lt;br /&gt;
3. If it from replay data and metadata not available:&lt;br /&gt;
: Nanoseconds from the input data.&lt;br /&gt;
: Periodic increments if source is frame-based, random increments if source is data-driven.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameAcqTime&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; || Duration of the frame, float in seconds. Always 0.000000 in data from data-driven sources.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;x, y&#039;&#039;&#039; || Position of the pixel.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;energy&#039;&#039;&#039;* || Energy deposited in the pixel. Integer ToT counter value if not calibrated, float in keV if calibrated.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;ToA&#039;&#039;&#039;* || Time of arrival, relative to frameStart. Integer in CLK ticks if ToA conversion is disabled, float in ns if ToA conversion is enabled.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;*&#039;&#039;&#039;ToA+energy records can be created from source that supports combined ToA+ToT modes, like as OPM_TOATOT on the Timepix3. If the data source supports only single modes, only one value is in this position.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;data-driven&#039;&#039;&#039; source &#039;&#039;&#039;not&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;frame-based&#039;&#039;&#039; source &#039;&#039;&#039;can&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix3, Frame2 with two clusters by 2 and 4 pixels, Frame3 with single 2-pixel cluster)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 2 (273697060.937500, 0.000000 s)&lt;br /&gt;
[214, 195, 43.1598, 0] [220, 191, 20.6515, 7.8125]&lt;br /&gt;
[224, 182, 21.8018, 31.25] [223, 186, 4.58576, 31.25] [222, 183, 38.2381, 31.25] [226, 185, 14.7623, 34.375]&lt;br /&gt;
&lt;br /&gt;
Frame 3 (371034565.625000, 0.000000 s)&lt;br /&gt;
[151, 33, 32.5745, 0] [151, 34, 13.8135, 17.1875]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 6 (1639143482.765164, 0.200000 s)&lt;br /&gt;
[87, 134, 5.75352] [217, 58, 14.8396]&lt;br /&gt;
Frame 7 (1639143483.019154, 0.200000 s)&lt;br /&gt;
Frame 8 (1639143483.261158, 0.200000 s)&lt;br /&gt;
Frame 9 (1639143483.513150, 0.200000 s)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| The &#039;&#039;&#039;CLOG.IDX&#039;&#039;&#039; files generated beside the CLOGs. Contains the simple binary array of little-endian qword addresses of the &amp;quot;F&amp;quot; at each record start.&amp;lt;br&amp;gt;&lt;br /&gt;
; .clog.idx example&lt;br /&gt;
: Pointers to records at 0, 0x29, 0x52, 0x7b, 0xA4, 0xCD, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The &#039;&#039;&#039;CLOG.IDX is different&#039;&#039;&#039; from ordinary ones [[#IDX files details|IDX files]].&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-clog-idx-example.png|frame|alt=Example .clog.idx file|Example .clog.idx file]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== PLOG files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Like as CLOG&#039;&#039;&#039;, but with simple lists of hit pixels of a frames.&lt;br /&gt;
* &#039;&#039;&#039;Metatdata section&#039;&#039;&#039; at start.&lt;br /&gt;
* &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format usable only with &#039;&#039;&#039;Timepix&#039;&#039;&#039; (first generation) chips.&lt;br /&gt;
:: Saved data are main frame only.&lt;br /&gt;
:: IDX is like CLOG.IDX, but items points to [ at start of each frame.&lt;br /&gt;
:: Recommended to use PMF with SPARSEX(Y) flag instead it.&lt;br /&gt;
&lt;br /&gt;
== Advapix specific data files ==&lt;br /&gt;
New data formats were created for early AdvaPIX variants based on special requirements, but their use was minimal. This chapter serves mainly in case you have such data from the past and need to process it with your software.&lt;br /&gt;
&lt;br /&gt;
=== BMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
This special file contains a &#039;&#039;&#039;binary matrix data from fast measurements&#039;&#039;&#039; (AdvaPIX-Tpx and ModuPIX devices).&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format for obsolete devices&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! BMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
To save theese files the Advapix-Timepix must be used, set the fast mode by setting acq. time 0.01 sec or shorter and frames count divisible by 100.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The file starts with 13 bytes long header and then is followed by pixel values of each frame. Each frame has a few dummy bytes at the beginning. So the layout of the file is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[HEADER][Frame 1][Frame 2][Frame 3] ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where header is 13 bytes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 width;&lt;br /&gt;
u32 height;&lt;br /&gt;
u32 offset;&lt;br /&gt;
char frameType;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;witdh&#039;&#039;&#039; and &#039;&#039;&#039;height&#039;&#039;&#039; is the dimensions of each frame.&lt;br /&gt;
* Each frame data is prepended by &#039;&#039;&#039;offset&#039;&#039;&#039; number of dummy bytes.&lt;br /&gt;
* The &#039;&#039;&#039;frameType&#039;&#039;&#039; specifies the type (variable type) of pixel values. It can be one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
CHAR = 0 (1 byte size)&lt;br /&gt;
BYTE = 1 (1 byte size) &lt;br /&gt;
I16 = 2 (2 bytes size)&lt;br /&gt;
U16 = 3 (2 bytes size)&lt;br /&gt;
I32 = 4 (4 bytes size) &lt;br /&gt;
U32 = 5 (4 bytes size)&lt;br /&gt;
I64 = 6 (8 bytes size)&lt;br /&gt;
U64 = 7 (8 bytes size)&lt;br /&gt;
FLOAT = 8 (4 bytes size)&lt;br /&gt;
DOUBLE = 9 (8 bytes size)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== AMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039;, special, rare format.&lt;br /&gt;
: This is the output of a mechanical &#039;&#039;&#039;assembly of four AdvaPIX-TPX&#039;&#039;&#039; devices, with &#039;&#039;&#039;four USB cables&#039;&#039;&#039;, which was then presented as the AdvaPIX TPX Quad. Not to be confused with the current AdvaPIX-Quad which has a single USB cable.&lt;br /&gt;
: Even if you have this set, don&#039;t save AMF unless you have a very special reason.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! AMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The amf is a binary file that contains data from all the devices combined into one stream of frame matrixes. The file consists of two parts a header (1000 bytes) and the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two versions of the file. Version 1 and Version 2. Version 1 has only one offset parameter, but had a bug, where frames were shifted in the file by 8 bytes. Version 2 has to frame data offsets - before frame data and after frame data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 1):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 1&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offset; // offset of each frame data in the frame block&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 2):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 2&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offsetBefore; // offset of the beginning of frame data in frame block&lt;br /&gt;
 u32 offsetAfter; // offset after frame data&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file may contain variable number of chips (not only data from AdvaPIX Quad = 4 chips).&lt;br /&gt;
* &#039;&#039;&#039;channelCount&#039;&#039;&#039; - How many chip are present in the file.&lt;br /&gt;
* &#039;&#039;&#039;chipsWidth&#039;&#039;&#039; and &#039;&#039;&#039;chipsHeight&#039;&#039;&#039; - How many chips are in x and y coordinate. For example for AdvaPIX Quad it is 2 by 2 (chipsWith = 2, chipsHeight = 2).&lt;br /&gt;
* &#039;&#039;&#039;chipLayout&#039;&#039;&#039; and &#039;&#039;&#039;chipAngles&#039;&#039;&#039; - When the device is read the order of chips is different than shown on the screen (depending on the layout of the internal chip interconnection). Therefore it is necessary to know AdvaPIX QUAD Multi-Frame Format (*.amf) order of the chips and they rotation to create correct image. chipLayout specifies order of the chip (the indexes starts from 0 to the index of last chip, from the top left to the right bottom). The chipAngles specifies rotation of each chip (0 = no rotation, 1 = 90 deg, 2 = 180, 3 = 270, all clockwise).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After the header file the frame data folows. The frame data are saved in frames blocks. Each block contain frames from each detector.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [FrameBlock1][FrameBlock2][FrameBlock3]...&lt;br /&gt;
Frame Block contains:&lt;br /&gt;
 [FrameData1][FrameData2][FrameData3][FrameData4]....&lt;br /&gt;
Each frame contains:&lt;br /&gt;
 [Offset][MatrixData(65536*2)] // Version 1 of the file&lt;br /&gt;
 [OffsetBefore][MatrixData(65536*2)][OffsetAfter] // Version 2 of the file&lt;br /&gt;
Each frame is prepended by an offset (specified in header, offsetBefore) and appended byt some dummy data of length offsetAfter. The frame pixels are saved as 16 bit unsigned integer. Each chip has 256x256 pixels. Therefore - 65536 * 2 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bug in Version 1 of the AMF File:&#039;&#039;&#039;&lt;br /&gt;
The version 1.0 of the AMF file contains bug, where the first frame in the data is missing first 8 bytes. To compensate in the code, when reading make the length of HEADER smaller by 8 bytes =&amp;gt; 992 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
Version 2 has size of offset before and after frame data instead.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offset;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = (HEADER_SIZE - 8) + offset&lt;br /&gt;
secondFrameDataPosition = (HEADER_SIZE - 8) + offset + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offsetBefore + offsetAfter;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = HEADER_SIZE + offsetBefore&lt;br /&gt;
secondFrameDataPosition = HEADER_SIZE + offsetBefore + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MCF and BPC ==&lt;br /&gt;
Old configuration formats. Was used for pixcfg or DACs. Use only to read old data. If it possible, save all old configurations in newer formats, such as XML, and do not use old files due to possible end of support.&lt;br /&gt;
&lt;br /&gt;
= Other files =&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_configuration_ini_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device configuration ini files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_firmware_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device firmware files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: &#039;&#039;&#039;BSTG files&#039;&#039;&#039;]] or see the &#039;&#039;&#039;Spectraimg and data files&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;User XML settings&#039;&#039;&#039;: See: The &#039;&#039;&#039;ISetting object&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;ASCII vertical *.vtxt&#039;&#039;&#039;: CSV-like file used in [[PIXet EDU|&#039;&#039;&#039;PIXet EDU&#039;&#039;&#039;]] and [[PIXet#Clustering_plugin|&#039;&#039;&#039;Clustering plugin&#039;&#039;&#039;]] for saving histograms&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Files and directories of the Pixet and SDK]]&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1707</id>
		<title>File types</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File_types&amp;diff=1707"/>
		<updated>2026-04-09T11:00:33Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* TIFF images */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Summary =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ General image/data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII frame&#039;&#039;&#039;. Text files with img lines converted to text lines with numbers separated by spaces.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pbf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet binary frame&#039;&#039;&#039;. Simple binary files, numbers only.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;pmf&#039;&#039;&#039; || &#039;&#039;&#039;Pixet multi frame&#039;&#039;&#039;. Default is same as the txt, but multiple frames on top of each other. Can use BINARY flag.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3pa&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels ASCII&#039;&#039;&#039;. Text, CSV-like format, tab-separated columns with the header in the first row. Biggest to saving.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3p&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 pixels&#039;&#039;&#039;. Binary format. Lower saved size than T3PA, contains simple repeats of 1 structure.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;t3r&#039;&#039;&#039; || &#039;&#039;&#039;Tpx3 raw&#039;&#039;&#039;. Complete data stream of Tpx3 chips. Lahge to saving, difficult to understand, slow to processing and can cause processing errors.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;png&#039;&#039;&#039; || Lossless compressed image. Easy to view, but not good for data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;tiff&#039;&#039;&#039; || &#039;&#039;&#039;TIFF, TIF&#039;&#039;&#039;, high bit-depth file usable in common graphic softwares or data processing.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;h5&#039;&#039;&#039; || &#039;&#039;&#039;HDF5&#039;&#039;&#039;, hierarchical data format 5. Used as one of multi-frame formats.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Files auxilliary for image/data&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;dsc&#039;&#039;&#039; || Text metadata list saved beside a standard multiframe files (PMF for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;info&#039;&#039;&#039; || Text metadata list saved beside other than standard multiframe files (T3PA for example).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;idx&#039;&#039;&#039; || Binary index for multi-frame files. Two formats existing.&amp;lt;br&amp;gt;&lt;br /&gt;
Usesfull for fast access to n-th frame of large text files, necessary for frame seeking in binary sparse files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Special data files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;clog, plog&#039;&#039;&#039; || &#039;&#039;&#039;Clusters/pixels logs&#039;&#039;&#039;. Text files contains clusters separated to frames with pixels lists. Historic formats for saving a data with few hited pixels in a frames. (&#039;&#039;&#039;obsolette&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bstg&#039;&#039;&#039; || &#039;&#039;&#039;Binary settings&#039;&#039;&#039; file. Measured or processed data with all configuration.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: BSTG files]] or see the &amp;quot;Spectraimg and data files&amp;quot; chapter in the Python API manual.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;vtxt&#039;&#039;&#039; || &#039;&#039;&#039;ASCII vertical&#039;&#039;&#039; CSV-like file used in PIXet EDU and Clustering plugin for saving histograms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&amp;quot;&lt;br /&gt;
|+ Configuration files&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40px;&amp;quot;| &#039;&#039;&#039;xml&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ini&#039;&#039;&#039; || See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
: &#039;&#039;&#039;Note&#039;&#039;&#039; Since 2025/09 release &#039;&#039;&#039;format changed&#039;&#039;&#039; to fully standard ini&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;txt&#039;&#039;&#039; ||&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;mcf&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
# DAC settings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;bpc&#039;&#039;&#039; ||&lt;br /&gt;
: &#039;&#039;&#039;OBSOLETE&#039;&#039;&#039;: Support can ended without previous warning&lt;br /&gt;
# Pixel matrix configuration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File type and extensions constants =&lt;br /&gt;
There are constants for file types and extensions. It can be used with [[Python API | &#039;&#039;&#039;Python API&#039;&#039;&#039;]] for filenames testing or with acquisition functions. But &#039;&#039;&#039;mostly PX_FTYPE_AUTODETECT will be enough&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Python example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Python&amp;gt;&lt;br /&gt;
# measure and save one 0.25 second frame to png file named &amp;quot;testFile.png&amp;quot;&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_PNG, &amp;quot;testFile&amp;quot;)&lt;br /&gt;
dev.doSimpleAcquisition(1, 0.25, pixet.PX_FTYPE_AUTODETECT, &amp;quot;testFile.png&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! colspan=3 | File types and extensions constants table &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! File type constants !! File extensions constants !! Ext value&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_NONE || (No direct file saving – data stored only in memory) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_AUTODETECT || (FTYPE detected by extension in a filename) ||&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_ASCII_FRAME || PX_EXT_ASCII_FRAME || &amp;quot;txt&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_FRAME || PX_EXT_BINARY_FRAME || &amp;quot;pbf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_MULTI_FRAME || PX_EXT_MULTI_FRAME || &amp;quot;pmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_BINARY_MULTIFRAME || PX_EXT_BINARY_MULTI_FRAME || &amp;quot;bmf&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS || PX_EXT_TPX3_PIXELS || &amp;quot;t3p&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_PIXELS_ASCII ||PX_EXT_TPX3_PIXELS_ASCII || &amp;quot;t3pa&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_CLUSTER_LOG || PX_EXT_CLUSTER_LOG || &amp;quot;clog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXEL_LOG || PX_EXT_PIXEL_LOG || &amp;quot;plog&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PNG || PX_EXT_PNG || &amp;quot;png&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_TPX3_RAW_DATA || PX_EXT_TPX3_RAW_DATA || &amp;quot;t3r&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_PIXET_RAW_DATA || PX_EXT_PIXET_RAW_DATA || &amp;quot;prd&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| PX_FTYPE_EXTERNAL || (reserved) ||&lt;br /&gt;
|-&lt;br /&gt;
| (description file saved automatically with pmf/txt) || PX_EXT_FRAME_DESC || &amp;quot;dsc&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| (index file saved automatically with pmf/txt) || PX_EXT_INDEX || &amp;quot;idx&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File saving flags summary =&lt;br /&gt;
File saving flags can do additional settings for file(s) saving.&lt;br /&gt;
* Can be used in &#039;&#039;&#039;saving&#039;&#039;&#039; files or in &#039;&#039;&#039;doAdvancedAcquisition&#039;&#039;&#039; python methods, for example.&lt;br /&gt;
* Flags can be combined.&lt;br /&gt;
* Default frame file settings is set of separate subframes text files, with all pixels include zeros, each subframe with idx+dsc files:&lt;br /&gt;
:: file_ToT.pmf, file_ToT.pmf.dsc, file_ToT.pmf.idx, file_ToA.pmf, file_ToA.pmf.dsc, file_ToA.pmf.idx&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ File saving flags&lt;br /&gt;
|-&lt;br /&gt;
! Flag constant base name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_BINARY || Use binary format in pmf.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEX || Index + non-zero pixels in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SPARSEXY || X, Y + non-zero pixel in file. # separates (sub)frames.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NODSC || Do not add dsc file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_NOSUBFRAMES || Do not use subframes, save main frame only.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_ONEFILE || Save all subframes to a single file.&lt;br /&gt;
|-&lt;br /&gt;
| PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME || Save separate all subframes and main frame extra.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The file saving flags can be used in&lt;br /&gt;
* &#039;&#039;&#039;Python API&#039;&#039;&#039;: Use pixet.PX_FRAMESAVE_... constants in flags parameter of some measuring/saving methods.&lt;br /&gt;
* &#039;&#039;&#039;Binary API&#039;&#039;&#039;: Use PX_FRAMESAVE_... constants in flags parameter of some measuring functions.&lt;br /&gt;
* The Pixet program. Available in the &#039;&#039;&#039;More measurement settings, after compatible filename was selected&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:File-flags-dialog.png|frame|alt=File saving flags in More measurement settings in Pixet|File saving flags in More measurement settings in Pixet]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= File extensions and flags: TXT/PBF/PMF details =&lt;br /&gt;
&lt;br /&gt;
== The files formats ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;width:50px;&amp;quot;| &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Text&#039;&#039;&#039; || Single frame in the text file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pbf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Binary&amp;amp;nbsp;Frame&#039;&#039;&#039; || Single frame in the binary file.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;pmf&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Pixet&amp;amp;nbsp;Multi&amp;amp;nbsp;Frame&#039;&#039;&#039; || Multiframe file with text or binary format, depends on flags used with saving.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;idx&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Index&#039;&#039;&#039; || Binary array of structs with 64b pointers to start of frames, frame metadata and subframes.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;dsc&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Description&#039;&#039;&#039; || List of all metadata for each frame and subframe. Actual device and acquisition parameters, data types, etc. The &amp;quot;Frame name&amp;quot; item can be helpful to orientation in pmf structure if the ONEFILE flag used. The Type=item is helpful to understanding the structure of data if the BINARY flag used.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multi-files names generation ==&lt;br /&gt;
; Note:&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; flags 0 (default), input filename = &amp;quot;name&amp;quot;, acqCount = 1&lt;br /&gt;
: name_ToA.txt, name_ToA.txt.dsc, name_ToT.txt, name_ToT.txt.dsc&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; acqCount = 6:&lt;br /&gt;
: name_0_ToA.txt, name_0_ToA.txt.dsc, name_0_ToT.txt, ...&lt;br /&gt;
: ...&lt;br /&gt;
: name_5_ToA.txt, name_5_ToA.txt.dsc, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PMF note&lt;br /&gt;
: With each pmf generating &#039;&#039;&#039;.pmf.idx&#039;&#039;&#039; binary file, other is same as TXT with acqCount = 1.&lt;br /&gt;
&lt;br /&gt;
== Files with flags=0 ==&lt;br /&gt;
; Note&lt;br /&gt;
: All the next examples are for Timepix3, single chip, opm = TPX3_OPM_TOATOT&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; TXT file data, default&lt;br /&gt;
: 0 0 0 5 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0 872 0 0 0 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: (256 lines)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PBF file data, default&lt;br /&gt;
: Simple pixels binary data without anything else&lt;br /&gt;
: Data can be typically 16 or 32 bit raw integers with little-endian order and doubles for calibrated data.&lt;br /&gt;
: For example, MiniPIX has single chip, this has 65536 pixels, it&#039;s binary file has 65536 words (size 128 kB binary), sometimes 65536 doubles (size 512 kB binary).&lt;br /&gt;
: The &#039;&#039;&#039;data format&#039;&#039;&#039; can be read in the line starting with Type= line in the [[#DSC files details | &#039;&#039;&#039;DSC file&#039;&#039;&#039;]] saved beside the data file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; PMF file data, default&lt;br /&gt;
: 0.00000 78.65742 0.00000 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter&lt;br /&gt;
: 0.00000 0.00000 999785.5 … 256 numbers (int for non-calibrated values or float if the calibration used) and enter &lt;br /&gt;
: (256 lines * acqCount)&lt;br /&gt;
&lt;br /&gt;
== Flags influence to files ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEX flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| _ToA.txt file !!colspan=&amp;quot;2&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &#039;&#039;&#039;px index&#039;&#039;&#039; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 227212.500000 || 0 || 20&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 310685.937500 || 17 || 13&lt;br /&gt;
|-&lt;br /&gt;
| 255 || 265487.500000 || 255 || 11&lt;br /&gt;
|-&lt;br /&gt;
| 1274 || 105728.125000 || 1274 || 9&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;4&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ TXT file data: FRAMESAVE_SPARSEXY flag&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;3&amp;quot;| _ToA.txt file !!colspan=&amp;quot;3&amp;quot;| _ToT.txt file&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToA&#039;&#039;&#039; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;X&#039;&#039;&#039;&amp;amp;nbsp; || &amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;Y&#039;&#039;&#039;&amp;amp;nbsp; || &#039;&#039;&#039;ToT&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| 247 || 3 || 189851.562500 || 247 || 3 || 16&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 4 || 140042.187500 || 250 || 4 || 12&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 9 || 317195.312500 || 5 || 9 || 5&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;6&amp;quot;| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;6&amp;quot;| - Lists of all hited pixels&amp;lt;br&amp;gt;- ToT: int for non-calibrated data or float if the calibration used&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;PMF file data, pixet.PX_FRAMESAVE_SPARSEX(Y) flag&#039;&#039;&#039;&amp;lt;br&amp;gt;Same as TXT, but containing single lines with only # to separate frames&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! X !! Y !! ToA !! Line description&lt;br /&gt;
|-&lt;br /&gt;
| 232 || 139 || 321620.312500 || frame 1, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 252 || 340231.250000 || frame 1, px 2&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;3&amp;quot;| # || frames separator&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 0 || 258270.312500 || frame 2, px 1&lt;br /&gt;
|-&lt;br /&gt;
| 201 || 0 || 76593.750000 || frame 2, px 2&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 1 || 268642.187500 || frame 2, px 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_ONEFILE&lt;br /&gt;
: All the data is in one file, subframes are placed one behind the other. If the measurement result has 10 frames with 2 subframes A/B, each _n TXT file contains 2 subrfames and the PMF contains 20 frames in order:&lt;br /&gt;
: sfr0A, sfr0B, sfr1A, sfr1B, ...&lt;br /&gt;
: The exact order and names of type of (sub)frames is listed in the DSC file. The DSC have separate records [Fn] for all the items.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_SUBFRAMES_SAVEMAINFRAME&lt;br /&gt;
: The group of the saved files contains the main frame and all subframes. Subframe files end in _sfrName, the main frame does not. In DSC file accompanying the TXT with main frame is not the &amp;quot;Frame name&amp;quot; item.&lt;br /&gt;
: Not applicable if combined with the &#039;&#039;&#039;ONEFILE&#039;&#039;&#039; flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; PX_FRAMESAVE_BINARY&lt;br /&gt;
: If the file type supports text and binary format, ex. PMF, save the binary.&lt;br /&gt;
: Not applicable to TXT, must use PBF instead.&lt;br /&gt;
: Data in the file are the simple array of non-calibrated 16 or 32b integers or calibrated doubles. See the DSC file for used data type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;BINARY + SPARSEXY examples:&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
[[File:File-binary-sparsexy-example.png|frame|none|alt=Example of data saved if flags BINARY+SPARSEXY used|Example of data saved if flags BINARY+SPARSEXY used]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Timepix3 specific data files =&lt;br /&gt;
The Timepix3 have the data-driven mode feature. It is &amp;quot;frameless&amp;quot; mode, where the device can continuously send the data of the pixels just hit indefinitely. Each sent pixel contains information:&lt;br /&gt;
# Pixel position index&lt;br /&gt;
# Event registration time (raw ToA count and FToA, conversion and corrections needed)&lt;br /&gt;
# Energy deposited in a pixel (raw ToT count, need conversion using the chip-specific calibration table containing cal. constants for each pixel)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Theese files can be very large. You can collecting a data from cosmic particles using Minipix continuously for more weeks and get a T3PA sized in tens of megabytes. But if some noising pixel occurs, a files can has many gygabytes per day. If the Advapix used with x-ray mashines or accelerators, the output data can has gigabytes in an instant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The formats:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;T3PA&#039;&#039;&#039; files are &#039;&#039;&#039;text/csv&#039;&#039;&#039; files with basic data. User can simply see it in text editor and process it in Python etc.&lt;br /&gt;
* &#039;&#039;&#039;T3P&#039;&#039;&#039; files are &#039;&#039;&#039;binary&#039;&#039;&#039; files with basic data same as T3PA. Faster saving, shorter files.&lt;br /&gt;
* &#039;&#039;&#039;T3R&#039;&#039;&#039; files are binary files with complete raw communication data. &#039;&#039;&#039;For special purposes only.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data order&#039;&#039;&#039;&lt;br /&gt;
* The order of the data roughly corresponds to the order of events, so data an hour later will definitely be further in the file.&lt;br /&gt;
* But the exact order corresponds to the order in which the data came from the device, so for example a later event that occurred at the edge where the chip is read can be recorded earlier than an earlier event that occurred further from the edge.&lt;br /&gt;
* The unevenness of the order occurs from tens of ns on a lightly loaded Advapix to several ms with a heavy load on the Minipix.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;How to get the files:&#039;&#039;&#039;&lt;br /&gt;
* In the [[PIXet|&#039;&#039;&#039;Pixet&#039;&#039;&#039;]] program set operation mode to ToA+ToT and use the &amp;quot;Pixels&amp;quot; measurement type and turn on file saving.&lt;br /&gt;
* In the [[Binary_core_API|&#039;&#039;&#039;binary API&#039;&#039;&#039;]] using programs set operation mode to PXC_TPX3_OPM_TOATOT and use the [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]] function.&lt;br /&gt;
* In the [[Python API|&#039;&#039;&#039;Python API&#039;&#039;&#039;]] using programs set operation mode to pixet.PX_TPX3_OPM_TOATOT and use the dev.&#039;&#039;&#039;doAdvancedAcqquisition&#039;&#039;&#039; with acqType=pixet.PX_ACQTYPE_DATADRIVEN.&lt;br /&gt;
&lt;br /&gt;
== T3PA files details ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 pixels ASCII file&#039;&#039;&#039; is timepix3 data file in text format with lines and tabs. Can be read as CSV, but its size is not limited to sizes readable by Office-like programs . Contains the header line and data lines with record index, pixel index in the matrix, Time of arrival, Time over threshold, Fine ToA and Overflow.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The T3PA example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Index   Matrix Index    ToA     ToT     FToA    Overflow&lt;br /&gt;
0       1028    1918    14      22      0&lt;br /&gt;
1       1028    3126    8       28      0&lt;br /&gt;
2       1028    3778    5       23      0&lt;br /&gt;
...&lt;br /&gt;
156003  39793   98473646054     38      9       0&lt;br /&gt;
156004  190     98492090610     19      3       0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Index&#039;&#039;&#039; is simple index of measurement line. This growing while measurement is running. If you append new measurement to existing file, new index is 0 again and again growing while new measurement is running.&lt;br /&gt;
[[File:Minipix-pixel00.png|frame|right|alt=Physical position of the x=0, y=0 pixel on the Minipix|Physical position of the x=0, y=0 pixel on the Minipix]]&lt;br /&gt;
* The &#039;&#039;&#039;Matrix Index&#039;&#039;&#039; is index of the pixel. On the Minipix Tpx3 is 0 at the left-down (see image)&lt;br /&gt;
* The &#039;&#039;&#039;ToA&#039;&#039;&#039; is time of arrival in units 25 ns, mod by limit specific by device type.&lt;br /&gt;
:: For example Minipix 2&amp;lt;sup&amp;gt;64&amp;lt;/sup&amp;gt; (14600y), Advapix-single 2&amp;lt;sup&amp;gt;30&amp;lt;/sup&amp;gt; (26s), Advapix-Quad 2&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (6.5s).&lt;br /&gt;
: &#039;&#039;&#039;Note:&#039;&#039;&#039; The ToA on-chip implementation in the pixels is limited to 14 bits (409.6 µs).&lt;br /&gt;
:: The ToA in T3PA is extended by device. But there is inherent uncertainty around the borders. These values may be incorrectly assigned. Users not comfortable with our extension can apply AND with (uint64)16383 to extended ToA to get original ToA from the chip.&lt;br /&gt;
* The &#039;&#039;&#039;ToT&#039;&#039;&#039; is time over threshold in units 25 ns.&lt;br /&gt;
* The &#039;&#039;&#039;FToA&#039;&#039;&#039; stands for &amp;quot;fine ToA&amp;quot; and it is the finest step of the ToA measurement. To properly account for this step in the conversion of ToA to time, it is necessary to subtract the amount of counts of fToA in the following manner:&lt;br /&gt;
:: &#039;&#039;&#039;Time [ns] = 25*ToA - (25/16)*fToA&#039;&#039;&#039;&lt;br /&gt;
: The original range of this fToA value in the chip is 4 bits, or 16 values. This is extended in the post-processing of the data into 5 bits, or 32 values to include a correction for Intentional phase shift of clocks propagated into the columns of the chip. The final value exported into t3pa files has a range of 5 bits, or 32 values, but the previous equation still stands.&lt;br /&gt;
* The &#039;&#039;&#039;Overflow&#039;&#039;&#039; is sign of data transfer overflow or other special cases.&lt;br /&gt;
:: &#039;&#039;&#039;Note:&#039;&#039;&#039; In data from multichip devices, there is not Overflow, replaced by Chip index (=copy of bits 16+ of Matrix Index. But column name is still Overflow).&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;1 - data transfer overflow&#039;&#039;&#039;:&lt;br /&gt;
::: matrix index = 0x74: start of lost data&lt;br /&gt;
::: matrix index = 0x75: end of lost data, toa is length of the missing time&lt;br /&gt;
::: (this can occurs with rates over megahits per seconds for Minipix)&lt;br /&gt;
::: matrix index = 0: Data corruption event detected - all next data can be corrupted&lt;br /&gt;
:* If the line has this &#039;&#039;&#039;10 - trigger timestamp&#039;&#039;&#039; (If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled):&lt;br /&gt;
::: matrix index = 0, ToT = 0&lt;br /&gt;
::: ToA = Timestamp of arrival external sync pulse to the device.&lt;br /&gt;
::: FToA = Count of expected ToA counter overflows.&lt;br /&gt;
::: If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, every sync pulse cause creating of one line record, independent of sync is or is not used to start of the acquisition. Timestamps can be recorded some time before the measurement starts. They may have zero or, conversely, an arbitrarily high value.&lt;br /&gt;
::: Warnings:&lt;br /&gt;
:::* Be careful about having too high values ​​in the FToA column (increment every 409.6 µs).&lt;br /&gt;
:::* Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&lt;br /&gt;
&lt;br /&gt;
* Related: [[The_RawTpx3Pixel_structure_in_memory#Explanation_of_the_struct|The RawTpx3Pixel structure in memory: Explanation of the struct]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If &#039;&#039;&#039;saving of the T3PA repeated to the same file&#039;&#039;&#039;, new data will be append with new reset of record index and ToA and the file containing parts is like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
507812	353	39993345	1022	15	0&lt;br /&gt;
507813	46177	39999843	159	2	0&lt;br /&gt;
507814	45921	39999843	159	2	0&lt;br /&gt;
0	421	2	13	29	0&lt;br /&gt;
1	297	2	22	27	0&lt;br /&gt;
2	297	145	62	17	0&lt;br /&gt;
3	297	283	19	13	0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3P files details ==&lt;br /&gt;
&#039;&#039;&#039;Timepix3 Binary Pixels&#039;&#039;&#039; is similar to t3pa file without record index. And the numbers are not saved as ASCII, but binary. The file contains one pixel after each other. Each pixel in this format:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 matrixIdx;&lt;br /&gt;
u64 toa;&lt;br /&gt;
byte overflow;&lt;br /&gt;
byte ftoa;&lt;br /&gt;
u16 tot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P file contents example:&#039;&#039;&#039;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ As see in a HEX editor&lt;br /&gt;
|- &lt;br /&gt;
| 5E86 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0300&lt;br /&gt;
|-&lt;br /&gt;
| 6087 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0005 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 6387 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 001B || 0100&lt;br /&gt;
|-&lt;br /&gt;
| 6486 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0400&lt;br /&gt;
|-&lt;br /&gt;
| 5D84 || 0000 || 1F0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0010 || 0200&lt;br /&gt;
|-&lt;br /&gt;
| 89BD || 0000 || 240B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0015 || 0D00&lt;br /&gt;
|-&lt;br /&gt;
| 5F80 || 0000 || 1E0B || 0000&lt;br /&gt;
|-&lt;br /&gt;
| 0000 || 0000 || 0002 || 0600&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; ||&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&lt;br /&gt;
|+ Redistributed according the structure&lt;br /&gt;
|-&lt;br /&gt;
! pxIdx&amp;lt;br&amp;gt;4 B !! ToA&amp;lt;br&amp;gt;8 B !! Over&amp;lt;br&amp;gt;1 B !! fToA&amp;lt;br&amp;gt;1 B !! ToT&amp;lt;br&amp;gt;2 B&lt;br /&gt;
|-&lt;br /&gt;
| 5E 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 03 00&lt;br /&gt;
|-&lt;br /&gt;
| 60 87 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 05 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 63 87 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 1B || 01 00&lt;br /&gt;
|-&lt;br /&gt;
| 64 86 00 00 || 1E 0B 00 00 00 00 00 00 || 00 || 15 || 04 00&lt;br /&gt;
|-&lt;br /&gt;
| 5D 84 00 00 || 1F 0B 00 00 00 00 00 00 || 00 || 10 || 02 00&lt;br /&gt;
|-&lt;br /&gt;
| 89 BD 00 00 || 24 0B 00 00 00 00 00 00 || 00 || 15 || 0D 00&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Corresponding start of T3PA&lt;br /&gt;
: Index &amp;amp;nbsp;	Matrix Index &amp;amp;nbsp;	ToA &amp;amp;nbsp;	ToT &amp;amp;nbsp;	FToA &amp;amp;nbsp;	Overflow&lt;br /&gt;
: 0  &amp;amp;nbsp; 34398  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 3  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 1  &amp;amp;nbsp; 34656  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 5  &amp;amp;nbsp; 0&lt;br /&gt;
: 2  &amp;amp;nbsp; 34659  &amp;amp;nbsp; 2847   &amp;amp;nbsp; 1  &amp;amp;nbsp; 27 &amp;amp;nbsp; 0&lt;br /&gt;
: 3  &amp;amp;nbsp; 34404  &amp;amp;nbsp; 2846   &amp;amp;nbsp; 4  &amp;amp;nbsp; 21 &amp;amp;nbsp; 0&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;Overflow value&#039;&#039;&#039; - Data transfer overflow indicator or other special value indicator.&amp;lt;br&amp;gt;&lt;br /&gt;
See [[#T3PA files details]] for details and see below for T3P differences in the trgTimeStamp.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;T3P files with trgTimeStamp&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Note: This is old internal testing feature and was not intended for mormal using. If you do want to use it, here&#039;s some info:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If the &#039;&#039;&#039;trgTimeStamp&#039;&#039;&#039; feature is enabled, file can contains lines of tab-divided ASCII numbers. Every record is six numbers divided by tabs (0x09) and ended with line end (0x0A).This is simple T3PA line. See the T3PA with overflow=10 for details.&amp;lt;br&amp;gt;&lt;br /&gt;
Warning: Primary internal development/testing feature. It is possible that other firmware versions has a different format and meaning of the numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Every sync pulse cause creating of one line record. In the file, each sync record and each pixel are simply stored in the order as it arrived on the computer. Any combination of order and number of binary and text records can be expected.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This is a source of complications when using the file. The file must be browsed sequentially as binary pixels. At the first occurrence of faulty or suspicious values (eg high pixel index, high ToA, Overflow&amp;gt;1) assume that the current record is not a pixel, but that the ASCII/tab line starts here and that it ends at 0A.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== T3R files ==&lt;br /&gt;
The &#039;&#039;&#039;Timepix3 Raw Data File&#039;&#039;&#039; is special format for testing purposes. This is a dump of raw communication from the device. The file format is device specific, binary, complex and files are very large. Use this only if you have no other option.&lt;br /&gt;
&lt;br /&gt;
= DSC/INFO metadata files =&lt;br /&gt;
The metadata text files are saved beside the data files and containing informations about device and settings used for measuring the data. It can be usable while openning the data file in the Pixet program or in other working with the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the API is used to saving the data, programmer can use callback like us &amp;quot;&#039;&#039;&#039;before saving data callback&#039;&#039;&#039;&amp;quot; to add Your specific metadata items or can remove items that will not need.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;DSC&#039;&#039;&#039; are files generated beside the frame data and cotaining information for each frame&lt;br /&gt;
* &#039;&#039;&#039;INFO&#039;&#039;&#039; are files generated beside pixel data and some special data formats&lt;br /&gt;
&lt;br /&gt;
== DSC files details ==&lt;br /&gt;
The first line is &#039;&#039;&#039;header line&#039;&#039;&#039;:&lt;br /&gt;
: Some like as &#039;&#039;&#039;A123456789&#039;&#039;&#039;: B=binary / A=ASCII and number = count of frames in multiframe data file&lt;br /&gt;
Next are &#039;&#039;&#039;frames&#039;&#039;&#039; in format:&lt;br /&gt;
: &#039;&#039;&#039;1. [Fn]&#039;&#039;&#039; - Frame with idx n start: [F0], [F1], ...&lt;br /&gt;
: &#039;&#039;&#039;2. Frame type&#039;&#039;&#039; - Data type, pixel format and frame size: Some like as &amp;quot;Type=i16 [X,C] width=256 height=256&amp;quot;&lt;br /&gt;
:: Pixels format options:&lt;br /&gt;
::: &#039;&#039;&#039;matrix&#039;&#039;&#039; - Whole matrix saved. Number of saved pixels are allways width*height.&lt;br /&gt;
:::: Multiframe data file not contains frame separator.&lt;br /&gt;
::: &#039;&#039;&#039;[X,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has matrix index and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
::: &#039;&#039;&#039;[X,Y,C]&#039;&#039;&#039; - Hit pixels only. Every saved pixel has X,Y position and data value.&lt;br /&gt;
:::: ASCII multiframe data file contains the frame separators.&lt;br /&gt;
:::: The IDX file must be used to find frame begins in binary multiframe file.&lt;br /&gt;
: &#039;&#039;&#039;3. Frame metadata&#039;&#039;&#039; - List of metadata items separated by blank lines:&lt;br /&gt;
::: Each metadata item is line triplet:&lt;br /&gt;
:# &amp;quot;Item name&amp;quot; (&amp;quot;Item description&amp;quot;): Example: &amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
:# DataType[valCount] Example: double[1]&lt;br /&gt;
:# Values list Example: 0.500000&lt;br /&gt;
:# (blank line)&lt;br /&gt;
: &#039;&#039;&#039;4. (blank line)&#039;&#039;&#039; - end of frame (there are two blank lines, the last metadata item end and the frame end)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In &#039;&#039;&#039;txt.dsc&#039;&#039;&#039; and &#039;&#039;&#039;pbf.dsc&#039;&#039;&#039;, end of the frame is end of the file.&amp;lt;br&amp;gt;&lt;br /&gt;
In the &#039;&#039;&#039;pmf.dsc&#039;&#039;&#039;, next frames or subframes metadata follows.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Some example (PBF 1 frame, with BINARY and SPARSEXY – test_49_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001                                      B=binary / A=ASCII and number = count of frames in multiframe file&lt;br /&gt;
[F0]                                            Index of frame in the file = 0&lt;br /&gt;
Type=double [X,Y,C] width=256 height=256        Data type double, X,Y,C = only hit pixels saved and has XY pos.&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):  Some metadata item name and (description)&lt;br /&gt;
u32[1]                                          Type of the item data [number of values]&lt;br /&gt;
49                                              The value&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA                                             This is the ToA frame&lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
(end of the file)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Other example (PMF 10 frames, with BINARY+SPARSEX+ONEFILE – test.pmf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000010&lt;br /&gt;
[F0]                                            Start of the first subframe&lt;br /&gt;
Type=double [X,C] width=256 height=256          Pixel index and double type pixel data (ToA in ns)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA &lt;br /&gt;
(more metadata items separated by blank lines …)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[F1]                                            Start of the second subframe&lt;br /&gt;
Type=i16 [X,C] width=256 height=256             Pixel index and i16 type pixel data (ToT in ticks 40MHz)&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
(and the ToT frame metadata, [F2] and ToA subframe, [F3] and ToT sfr, … [Fn] and ToT sfr of (n/2)th frame)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Complete one frame DSC example (PMF 1 frame, BINARY+SPARSEX – test_15_ToA.pbf.dsc):&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
B000000001&lt;br /&gt;
[F0]&lt;br /&gt;
Type=double [X,C] width=256 height=256&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
15&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059034.903085 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
0.500000&lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
I08-W0060&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1301 501 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Frame name&amp;quot; (&amp;quot;Frame name&amp;quot;):&lt;br /&gt;
char[3]&lt;br /&gt;
ToA&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-500 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.7.8&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1639059042.934810 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Thu Dec 9 15:10:42.934809 2021&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.026744&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== INFO files details ==&lt;br /&gt;
* The T3PA.INFO containing metadata in format very similar to one frame of DSC file.&lt;br /&gt;
* Some other INFO files can containing simpliest formated metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;T3PA.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[FileInfo]&lt;br /&gt;
&amp;quot;Acq Serie Index&amp;quot; (&amp;quot;Acquisition serie index&amp;quot;):&lt;br /&gt;
u32[1]&lt;br /&gt;
0 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq Serie Start time&amp;quot; (&amp;quot;Acquisition serie start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.719000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Acq time&amp;quot; (&amp;quot;Acquisition time [s]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1.000000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;ChipboardID&amp;quot; (&amp;quot;Chipboard ID&amp;quot;):&lt;br /&gt;
char[9]&lt;br /&gt;
D06-W0065&lt;br /&gt;
&lt;br /&gt;
&amp;quot;DACs&amp;quot; (&amp;quot;DACs&amp;quot;):&lt;br /&gt;
u16[19]&lt;br /&gt;
16 8 128 10 120 1237 437 5 16 8 16 8 40 128 128 128 256 128 128 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;HV&amp;quot; (&amp;quot;High voltage [V]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
-450 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Interface&amp;quot; (&amp;quot;Readout interface&amp;quot;):&lt;br /&gt;
char[7]&lt;br /&gt;
MiniPIX&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Mpx type&amp;quot; (&amp;quot;Medipix type (1-MXR, 2-TPX, 3-MPX3, 4-TPX3, 5-TPX2)&amp;quot;):&lt;br /&gt;
i32[1]&lt;br /&gt;
4 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Pixet version&amp;quot; (&amp;quot;Pixet version&amp;quot;):&lt;br /&gt;
char[5]&lt;br /&gt;
1.8.1&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Shutter open time&amp;quot; (&amp;quot;Shutter open timestamp&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
1704809538.867000 &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
char[64]&lt;br /&gt;
Tue Jan  9 15:12:18.867000 2024&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Threshold&amp;quot; (&amp;quot;Threshold [keV]&amp;quot;):&lt;br /&gt;
double[1]&lt;br /&gt;
5.015797 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%; overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;The &#039;&#039;&#039;BMF.INFO example:&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[File Meta Data]&lt;br /&gt;
Acq Serie Index:0&lt;br /&gt;
Acq Serie Start time:1704813831.469&lt;br /&gt;
Acq time:0.001&lt;br /&gt;
ChipboardID:G03-W0259&lt;br /&gt;
DACs:10 100 255 127 127 0 153 6 130 100 80 85 128 128&lt;br /&gt;
HV:-450&lt;br /&gt;
Interface:AdvaPIX&lt;br /&gt;
Mpx type:2&lt;br /&gt;
Pixet version:1.8.1&lt;br /&gt;
Start time:1704813831.633&lt;br /&gt;
Start time (string):Tue Jan  9 16:23:51.633000 2024&lt;br /&gt;
Threshold:5.02649397407217&lt;br /&gt;
Timepix clock:50&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= IDX files details =&lt;br /&gt;
The IDX files are generated with multiframe files to help with fast seeking frames in files. &#039;&#039;&#039;Each frame except first&#039;&#039;&#039; has the basic structure in the IDX file:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct IndexItem {&lt;br /&gt;
 i64 dscPos;    // frame position in the DSC file&lt;br /&gt;
 i64 dataPos;   // frame position in the main data file&lt;br /&gt;
 i64 sfPos;     // subframe position if exist subframes file next to the main data file (usually not and =0)&lt;br /&gt;
};&lt;br /&gt;
// Note: CLOG.IDX has no this structure, this in only i64 pointers to frames&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;PMF.IDX&#039;&#039;&#039; files generated beside the PMFs. Contains the simple binary array of structs of 3 little-endian qwords with addresses associated to the start of each frame except first: DSC, frame and subframe.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
; .pmf.idx with BINARY+ONEFILE, ToA+ToT example&lt;br /&gt;
: main data contains&lt;br /&gt;
:* ToA subframes (double*0x10000 = len 0x80000)&lt;br /&gt;
:* ToT subframes (i16*0x10000 = len 0x20000)&lt;br /&gt;
The IDX contains&lt;br /&gt;
# Pointers to frames in DSC file at 0 (not in idx), 0x03B5, 0x075D, 0x0B08, 0x0BE0, ... (points to an empty line before [Fx] line)&lt;br /&gt;
# Pointers to frames in main data file at 0 (not in idx), 0x080000, 0x0A0000, 0x120000, 0x140000, 0x1C0000, ...&lt;br /&gt;
# Pointers to frames in additional subframes file (not exist -&amp;gt; all=0)&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-pmf-idx-example.png|frame|right|alt=.pmf.idx file example|.pmf.idx file example]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= HDF5 files =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| The HDF5 (&#039;&#039;&#039;.H5&#039;&#039;&#039;) files are general standard binary containers for structured data. If used to save, contains both measured data and metadata.&lt;br /&gt;
* To access theese files, use third party tools like as:&lt;br /&gt;
:* &#039;&#039;&#039;HDFview&#039;&#039;&#039; from HDF Group&lt;br /&gt;
:* &#039;&#039;&#039;h5py&#039;&#039;&#039; python library from HDF Group&lt;br /&gt;
:: See: [[Python_API#Examples|&#039;&#039;&#039;Python API: Examples&#039;&#039;&#039;]] for reading using Python&lt;br /&gt;
:* &#039;&#039;&#039;HDF5 C++ API&#039;&#039;&#039; from HDF Group&lt;br /&gt;
* If you are saving from the API without Pixet, the &#039;&#039;&#039;hdf5io.dll&#039;&#039;&#039; plugin must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the hdf5io plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\hdf5io.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Saving a HDF5 files ==&lt;br /&gt;
* The files can be saved from the Pixet program or by API.&lt;br /&gt;
: [[File:Files-hdf5-saving-pixet.png|frame|none|alt=Saving HDF5 from the Pixet program|Saving HDF5 from the Pixet program:&amp;lt;br&amp;gt;First was saved the &#039;&#039;&#039;test.h5&#039;&#039;&#039;, second the &#039;&#039;&#039;test.h5:meas2&#039;&#039;&#039;]]&lt;br /&gt;
* When saving to an existing file, the data is added to the existing structure in it.&lt;br /&gt;
* Use the AUTODETECT filetype in the API functions using filetype.&lt;br /&gt;
* Saving flags will be ignored.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; Next image showing 3 files in the HDFview program&lt;br /&gt;
# File test1.h5 saved by acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
# File test2.h5 saved by tripple acquisitions of 10 frames, with filename settings &amp;quot;test1.h5:set0&amp;quot;,  &amp;quot;test1.h5:set1&amp;quot; and  &amp;quot;test1.h5:set2&amp;quot;.&lt;br /&gt;
# File test1.h5, existing from first acq., saved again in next acquisition of 10 frames with no additional filename settings.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-hdf5-examples.png|frame|none|alt=HDF5 files examples in HDFview|HDF5 files examples in HDFview: Single acq. with 10 frames, triple with structure, first file after second acq.]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The files was saved from the PY script:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=Python start=60&amp;gt;&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test1.h5&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set0&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set1&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
fName = out_dir + &amp;quot;test2.h5:set2&amp;quot;&lt;br /&gt;
print(&amp;quot;doSimpleAcquisition&amp;quot;, fName, &amp;quot;...&amp;quot;)&lt;br /&gt;
rc = dev.doSimpleAcquisition(10, 0.1, pixet.PX_FTYPE_AUTODETECT, fName)&lt;br /&gt;
if rc==0: print(&amp;quot;OK&amp;quot;)&lt;br /&gt;
else:     print(&amp;quot;error:&amp;quot;, rc, dev.lastError())&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Pixet structures in HDF5 ==&lt;br /&gt;
As see at the &amp;quot;HDF5 files examples&amp;quot; image in the previous chapter, the acquisition creates the file with structure (or adds to existing):&lt;br /&gt;
# Root name or path if defined by adding :hdfpath at end of filename (optional)&lt;br /&gt;
# Frame list: Frame_0, Frame_1, ...&lt;br /&gt;
# Main frame data: The Data item&lt;br /&gt;
# Basic informations items: AcqTime, Width, Height, StartTime&lt;br /&gt;
# MetaData directory containing same data as saved to the dsc files alongise classic simple data files.&lt;br /&gt;
# SubFrames directory with subframes subdirs named by subframe names (ToA, ToT, Event, iToT, ...) containing same structures as the main frame.&lt;br /&gt;
&lt;br /&gt;
= TIFF images =&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|rowspan=2| The TIFF (&#039;&#039;&#039;.TIFF / .TIF&#039;&#039;&#039;) &amp;quot;Tag Image File Format&amp;quot;, files are image format for high-resolution and high-bitDepth data and has multi-page support. If used to save, contains measured data in 32 bit integer format.&lt;br /&gt;
* If saving from API without the Pixet program, the &#039;&#039;&#039;tiffio.dll plugin&#039;&#039;&#039; must still be found and listed in the [plugins] section of the pixet.ini file.&lt;br /&gt;
:* See example right &amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
:* Note&amp;lt;nowiki&amp;gt;:&amp;lt;/nowiki&amp;gt; The library is not in the API package. Copy it from the plugins directory in the Pixet program pckage.&lt;br /&gt;
:* See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]* Note: Multipage format is not yet supported in Pixet. &lt;br /&gt;
* To simplify further data processing, Pixet saving an integer data only in 32bit format without any conversion. Or if data is double/float, the conversion factor is used (change it in the File output tab on Measurement settings dialog).&lt;br /&gt;
* To facilitate processing, an &#039;&#039;&#039;auxiliary file .tiff.aux.xml&#039;&#039;&#039; is also saved with the image. Note: Contents are completelly different from DSC/INFO files.&lt;br /&gt;
* It very often happens that integer data has negligible values ​​against the range of 32 bits (over 4 billion). This can cause the image &#039;&#039;&#039;looks like completely black&#039;&#039;&#039; when viewed in some programs, even though it contains data.&lt;br /&gt;
* The image can be shown in the Pixet. Drag-drop the image to the image zone. Recommended view settings: Auto range / Smart&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;pixet.ini example with the tiffio plugin:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlib=hwlibs\minipix.dll&lt;br /&gt;
hwlib=hwlibs\zem.dll&lt;br /&gt;
hwlib=hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugin=plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&#039;&#039;&#039;(Old pixet.ini format)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=ini highlight=10,11&amp;gt;&lt;br /&gt;
[Settings]&lt;br /&gt;
UseAppDataDir=false&lt;br /&gt;
FactoryDir=C:\Advacam\_factory&lt;br /&gt;
&lt;br /&gt;
[Hwlibs]&lt;br /&gt;
hwlibs\minipix.dll&lt;br /&gt;
hwlibs\zem.dll&lt;br /&gt;
hwlibs\zest.dll&lt;br /&gt;
&lt;br /&gt;
[Plugins]&lt;br /&gt;
plugins\tiffio.dll&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|[[File:Plugin-tiff.png|thumb|alt=TIFF plugin files in plugins directory|TIFF plugin files in the plugins directory]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Configuration files =&lt;br /&gt;
Ecosystem of the Pixet software containing many configuration files and formats. Part of this was inherited from the old Pixelman program. Do not use formats marked OBSOLETE to save new data. Load old data and save it to new formats before support ends.&lt;br /&gt;
&lt;br /&gt;
== Calibration files ==&lt;br /&gt;
# Threshold DAC/energy curves of every pixel are different. For proper device function the threshold adjustment matrix needed. This data is part of the pixel matrix configuration and it is part of the device XML config file.&lt;br /&gt;
# If the readout chip supports energy measuremnts, You need calibration data for convert digital data to the energy in keVs. Every pixel has own calibration coeficients. It&#039;s values depends on sensor chip local differences.&lt;br /&gt;
::* Calibration in the device config file - simpliest variant. The device config file contains calibration section with encoded binary data.&lt;br /&gt;
::* Set of the calibration files - files named name_a.txt, name_b.txt, name_c.txt and name_t.txt. Data is in the text matrix like in the frame files.&lt;br /&gt;
::* Most functions support using filename &amp;quot;name.xml&amp;quot; or &amp;quot;name_a.txt|name_b.txt|name_c.txt|name_t.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix configuration files ==&lt;br /&gt;
Contains matrix of:&lt;br /&gt;
# threshold adjustment bits of the pixel&lt;br /&gt;
# if the pixel is masked&lt;br /&gt;
# if test is on&lt;br /&gt;
# other bits depending on the chip type&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Overview&lt;br /&gt;
|-&lt;br /&gt;
! &amp;amp;nbsp;&#039;&#039;&#039;bpc&#039;&#039;&#039;&amp;amp;nbsp;&lt;br /&gt;
|| &#039;&#039;&#039;Binary Pixel Configuration&#039;&#039;&#039; || All PM config in one file, meaning of the bits depends on the chip.&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Mask Matrix&#039;&#039;&#039; || Text file with pixel mask&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii Test Bit Matrix&#039;&#039;&#039; || Text file with test bits&lt;br /&gt;
|-&lt;br /&gt;
! &#039;&#039;&#039;txt&#039;&#039;&#039; &lt;br /&gt;
|| &#039;&#039;&#039;Ascii THL adj. bits Matrix&#039;&#039;&#039; || Text file with threshold values adjustment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== XML format ==&lt;br /&gt;
Standard XML files&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;Device settings&#039;&#039;&#039;. Device configuration and calibration files. Name like as MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet Pro devcontrol settings&#039;&#039;&#039; Name like as devcontrol_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;Pixet EDU devcontrol settings&#039;&#039;&#039; Name like as eduview_MiniPIX-A06-W0050.xml.&lt;br /&gt;
# &#039;&#039;&#039;User configuration&#039;&#039;&#039; files from ISettings object&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|&#039;&#039;&#039;#Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== INI format ==&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; Main configuration file of the Pixet core&lt;br /&gt;
# &#039;&#039;&#039;hwlibname.ini&#039;&#039;&#039; Configuration of single hwlib. Name like as minipix.ini, zem.ini, zest.ini...&lt;br /&gt;
# &#039;&#039;&#039;pluginname.ini&#039;&#039;&#039; Configuration of a plugin in the Pixet program.&lt;br /&gt;
See [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|&#039;&#039;&#039;pixet.ini file&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: The original implementation in Pixet environment &#039;&#039;&#039;was non-standard&#039;&#039;&#039;. Older files have sections, such as [hwlibs], which contain values ​​themselves without name= beginnings.&lt;br /&gt;
: Starting &#039;&#039;&#039;from 2025/09 we are switching to standard INI&#039;&#039;&#039;. In sections where previously item beginnings were missing, we have switched to named items, where the name does not matter.&lt;br /&gt;
&lt;br /&gt;
== TXT format ==&lt;br /&gt;
All except DAC settings is simple matrix with lines containing numbers separated by spaces.&amp;lt;br&amp;gt;&lt;br /&gt;
; Used for&lt;br /&gt;
# &#039;&#039;&#039;(ASCII frames)&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Calibation files&#039;&#039;&#039; Set of 4 txt files with ASCII frames containing abct constants for each pixel&lt;br /&gt;
# &#039;&#039;&#039;Pixel matrix configuration&#039;&#039;&#039; ASCII frame containing complete pixel matrix configuration, mask bits, test bits, or THL adjustments.&lt;br /&gt;
# &#039;&#039;&#039;DAC settings&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Obsolete files =&lt;br /&gt;
All formats in this chapter are obsolete and, with the exception of CLOG, has not used for long time and it is possible that their support will be removed.&lt;br /&gt;
Pay attention to possible ambiguities when using CLOG.&lt;br /&gt;
&lt;br /&gt;
== CLOG and PLOG files ==&lt;br /&gt;
Old text formats from age of the first Timepix chips. Due to the new use with Tpx3, new ambiguities in CLOG have arisen.&lt;br /&gt;
* &#039;&#039;&#039;CLOG&#039;&#039;&#039; (clusters log) has remained popular in the context of cluster processing.&lt;br /&gt;
* &#039;&#039;&#039;PLOG&#039;&#039;&#039; (pixels log) is currently no longer used.&lt;br /&gt;
&lt;br /&gt;
=== CLOG and CLOG.IDX files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
The CLOG format was developed to facilitate further processing of cluster data by the user programs. This is a text file divided to the frame records and the records can contain a clusters. Frames and clusters are separated by the line breaks. Frames can be separated by whole free line.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
; The record format&lt;br /&gt;
: Frame FN (frameStart, frameAcqTime s)&lt;br /&gt;
: [x, y, energy, ToA] [x, y, energy, ToA] [x, y, energy, ToA] ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;FN&#039;&#039;&#039; || Frame index number. First 0 or 1.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameStart&#039;&#039;&#039; || Start time of the frame. There are variants:&lt;br /&gt;
1. If it from measuring or from replay frame-based data with metadata available:&lt;br /&gt;
: Linux format, frame starting time from PC’s getPrecisionTime.&lt;br /&gt;
2. If it from pixel-based data with metadata available (file.t3pa + file.t3pa.info):&lt;br /&gt;
: Linux format, acq. starting time from PC’s getPrecisionTime with added time from data.&lt;br /&gt;
3. If it from replay data and metadata not available:&lt;br /&gt;
: Nanoseconds from the input data.&lt;br /&gt;
: Periodic increments if source is frame-based, random increments if source is data-driven.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;frameAcqTime&#039;&#039;&#039;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; || Duration of the frame, float in seconds. Always 0.000000 in data from data-driven sources.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;x, y&#039;&#039;&#039; || Position of the pixel.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;energy&#039;&#039;&#039;* || Energy deposited in the pixel. Integer ToT counter value if not calibrated, float in keV if calibrated.&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &#039;&#039;&#039;ToA&#039;&#039;&#039;* || Time of arrival, relative to frameStart. Integer in CLK ticks if ToA conversion is disabled, float in ns if ToA conversion is enabled.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;*&#039;&#039;&#039;ToA+energy records can be created from source that supports combined ToA+ToT modes, like as OPM_TOATOT on the Timepix3. If the data source supports only single modes, only one value is in this position.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;data-driven&#039;&#039;&#039; source &#039;&#039;&#039;not&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
Clog from &#039;&#039;&#039;frame-based&#039;&#039;&#039; source &#039;&#039;&#039;can&#039;&#039;&#039; contains free frames.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix3, Frame2 with two clusters by 2 and 4 pixels, Frame3 with single 2-pixel cluster)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 2 (273697060.937500, 0.000000 s)&lt;br /&gt;
[214, 195, 43.1598, 0] [220, 191, 20.6515, 7.8125]&lt;br /&gt;
[224, 182, 21.8018, 31.25] [223, 186, 4.58576, 31.25] [222, 183, 38.2381, 31.25] [226, 185, 14.7623, 34.375]&lt;br /&gt;
&lt;br /&gt;
Frame 3 (371034565.625000, 0.000000 s)&lt;br /&gt;
[151, 33, 32.5745, 0] [151, 34, 13.8135, 17.1875]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example records&#039;&#039;&#039; (Timepix)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Frame 6 (1639143482.765164, 0.200000 s)&lt;br /&gt;
[87, 134, 5.75352] [217, 58, 14.8396]&lt;br /&gt;
Frame 7 (1639143483.019154, 0.200000 s)&lt;br /&gt;
Frame 8 (1639143483.261158, 0.200000 s)&lt;br /&gt;
Frame 9 (1639143483.513150, 0.200000 s)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| The &#039;&#039;&#039;CLOG.IDX&#039;&#039;&#039; files generated beside the CLOGs. Contains the simple binary array of little-endian qword addresses of the &amp;quot;F&amp;quot; at each record start.&amp;lt;br&amp;gt;&lt;br /&gt;
; .clog.idx example&lt;br /&gt;
: Pointers to records at 0, 0x29, 0x52, 0x7b, 0xA4, 0xCD, ...&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The &#039;&#039;&#039;CLOG.IDX is different&#039;&#039;&#039; from ordinary ones [[#IDX files details|IDX files]].&lt;br /&gt;
|| &lt;br /&gt;
[[File:File-clog-idx-example.png|frame|alt=Example .clog.idx file|Example .clog.idx file]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== PLOG files details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Like as CLOG&#039;&#039;&#039;, but with simple lists of hit pixels of a frames.&lt;br /&gt;
* &#039;&#039;&#039;Metatdata section&#039;&#039;&#039; at start.&lt;br /&gt;
* &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format usable only with &#039;&#039;&#039;Timepix&#039;&#039;&#039; (first generation) chips.&lt;br /&gt;
:: Saved data are main frame only.&lt;br /&gt;
:: IDX is like CLOG.IDX, but items points to [ at start of each frame.&lt;br /&gt;
:: Recommended to use PMF with SPARSEX(Y) flag instead it.&lt;br /&gt;
&lt;br /&gt;
== Advapix specific data files ==&lt;br /&gt;
New data formats were created for early AdvaPIX variants based on special requirements, but their use was minimal. This chapter serves mainly in case you have such data from the past and need to process it with your software.&lt;br /&gt;
&lt;br /&gt;
=== BMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
This special file contains a &#039;&#039;&#039;binary matrix data from fast measurements&#039;&#039;&#039; (AdvaPIX-Tpx and ModuPIX devices).&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039; format for obsolete devices&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! BMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
To save theese files the Advapix-Timepix must be used, set the fast mode by setting acq. time 0.01 sec or shorter and frames count divisible by 100.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The file starts with 13 bytes long header and then is followed by pixel values of each frame. Each frame has a few dummy bytes at the beginning. So the layout of the file is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[HEADER][Frame 1][Frame 2][Frame 3] ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where header is 13 bytes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
u32 width;&lt;br /&gt;
u32 height;&lt;br /&gt;
u32 offset;&lt;br /&gt;
char frameType;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;witdh&#039;&#039;&#039; and &#039;&#039;&#039;height&#039;&#039;&#039; is the dimensions of each frame.&lt;br /&gt;
* Each frame data is prepended by &#039;&#039;&#039;offset&#039;&#039;&#039; number of dummy bytes.&lt;br /&gt;
* The &#039;&#039;&#039;frameType&#039;&#039;&#039; specifies the type (variable type) of pixel values. It can be one of the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
CHAR = 0 (1 byte size)&lt;br /&gt;
BYTE = 1 (1 byte size) &lt;br /&gt;
I16 = 2 (2 bytes size)&lt;br /&gt;
U16 = 3 (2 bytes size)&lt;br /&gt;
I32 = 4 (4 bytes size) &lt;br /&gt;
U32 = 5 (4 bytes size)&lt;br /&gt;
I64 = 6 (8 bytes size)&lt;br /&gt;
U64 = 7 (8 bytes size)&lt;br /&gt;
FLOAT = 8 (4 bytes size)&lt;br /&gt;
DOUBLE = 9 (8 bytes size)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== AMF details ===&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
; Notes&lt;br /&gt;
: &#039;&#039;&#039;Obsolete&#039;&#039;&#039;, special, rare format.&lt;br /&gt;
: This is the output of a mechanical &#039;&#039;&#039;assembly of four AdvaPIX-TPX&#039;&#039;&#039; devices, with &#039;&#039;&#039;four USB cables&#039;&#039;&#039;, which was then presented as the AdvaPIX TPX Quad. Not to be confused with the current AdvaPIX-Quad which has a single USB cable.&lt;br /&gt;
: Even if you have this set, don&#039;t save AMF unless you have a very special reason.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&lt;br /&gt;
! AMF files details&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The amf is a binary file that contains data from all the devices combined into one stream of frame matrixes. The file consists of two parts a header (1000 bytes) and the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two versions of the file. Version 1 and Version 2. Version 1 has only one offset parameter, but had a bug, where frames were shifted in the file by 8 bytes. Version 2 has to frame data offsets - before frame data and after frame data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 1):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 1&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offset; // offset of each frame data in the frame block&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Header (version 2):&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
struct header {&lt;br /&gt;
 byte magic[3]; // AMF &lt;br /&gt;
 byte ver; // 2&lt;br /&gt;
 u32 channelCount;&lt;br /&gt;
 u32 offsetBefore; // offset of the beginning of frame data in frame block&lt;br /&gt;
 u32 offsetAfter; // offset after frame data&lt;br /&gt;
 u32 chipsWidth; // number of chips in x coordinate&lt;br /&gt;
 u32 chipsHeight; // number of chips in y coordinate&lt;br /&gt;
 byte chipLayout[256]; // order of chips&lt;br /&gt;
 byte chipAngles[256]; // rotation of chips&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file may contain variable number of chips (not only data from AdvaPIX Quad = 4 chips).&lt;br /&gt;
* &#039;&#039;&#039;channelCount&#039;&#039;&#039; - How many chip are present in the file.&lt;br /&gt;
* &#039;&#039;&#039;chipsWidth&#039;&#039;&#039; and &#039;&#039;&#039;chipsHeight&#039;&#039;&#039; - How many chips are in x and y coordinate. For example for AdvaPIX Quad it is 2 by 2 (chipsWith = 2, chipsHeight = 2).&lt;br /&gt;
* &#039;&#039;&#039;chipLayout&#039;&#039;&#039; and &#039;&#039;&#039;chipAngles&#039;&#039;&#039; - When the device is read the order of chips is different than shown on the screen (depending on the layout of the internal chip interconnection). Therefore it is necessary to know AdvaPIX QUAD Multi-Frame Format (*.amf) order of the chips and they rotation to create correct image. chipLayout specifies order of the chip (the indexes starts from 0 to the index of last chip, from the top left to the right bottom). The chipAngles specifies rotation of each chip (0 = no rotation, 1 = 90 deg, 2 = 180, 3 = 270, all clockwise).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After the header file the frame data folows. The frame data are saved in frames blocks. Each block contain frames from each detector.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [FrameBlock1][FrameBlock2][FrameBlock3]...&lt;br /&gt;
Frame Block contains:&lt;br /&gt;
 [FrameData1][FrameData2][FrameData3][FrameData4]....&lt;br /&gt;
Each frame contains:&lt;br /&gt;
 [Offset][MatrixData(65536*2)] // Version 1 of the file&lt;br /&gt;
 [OffsetBefore][MatrixData(65536*2)][OffsetAfter] // Version 2 of the file&lt;br /&gt;
Each frame is prepended by an offset (specified in header, offsetBefore) and appended byt some dummy data of length offsetAfter. The frame pixels are saved as 16 bit unsigned integer. Each chip has 256x256 pixels. Therefore - 65536 * 2 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bug in Version 1 of the AMF File:&#039;&#039;&#039;&lt;br /&gt;
The version 1.0 of the AMF file contains bug, where the first frame in the data is missing first 8 bytes. To compensate in the code, when reading make the length of HEADER smaller by 8 bytes =&amp;gt; 992 bytes.&amp;lt;br&amp;gt;&lt;br /&gt;
Version 2 has size of offset before and after frame data instead.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offset;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = (HEADER_SIZE - 8) + offset&lt;br /&gt;
secondFrameDataPosition = (HEADER_SIZE - 8) + offset + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2.0 Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=C&amp;gt;&lt;br /&gt;
#define HEADER_SIZE 1000&lt;br /&gt;
frameSizeInBytes = 65536 * 2 + offsetBefore + offsetAfter;&lt;br /&gt;
numberOfFramesInFile = (fileSizeInBytes - HEADER_SIZE) / frameSizeInBytes / channelCount&lt;br /&gt;
firstFrameDataPosition = HEADER_SIZE + offsetBefore&lt;br /&gt;
secondFrameDataPosition = HEADER_SIZE + offsetBefore + frameSizeInBytes * 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MCF and BPC ==&lt;br /&gt;
Old configuration formats. Was used for pixcfg or DACs. Use only to read old data. If it possible, save all old configurations in newer formats, such as XML, and do not use old files due to possible end of support.&lt;br /&gt;
&lt;br /&gt;
= Other files =&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#pixet.ini_file|Files and directories of the Pixet and SDK: &#039;&#039;&#039;pixet.ini&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Configuration XML files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_configuration_ini_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device configuration ini files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Files_and_directories_of_the_Pixet_and_SDK#Device_firmware_files|Files and directories of the Pixet and SDK: &#039;&#039;&#039;Device firmware files&#039;&#039;&#039;]]&lt;br /&gt;
* See: [[Binary_Spectral_Imaging_API#BSTG_files:_pxpSiSaveToFile_and_pxpSiLoadFromFile|Binary Spectral Imaging API: &#039;&#039;&#039;BSTG files&#039;&#039;&#039;]] or see the &#039;&#039;&#039;Spectraimg and data files&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;User XML settings&#039;&#039;&#039;: See: The &#039;&#039;&#039;ISetting object&#039;&#039;&#039; chapter in the &#039;&#039;&#039;Python API manual&#039;&#039;&#039; (PDF included in API package)&lt;br /&gt;
* &#039;&#039;&#039;ASCII vertical *.vtxt&#039;&#039;&#039;: CSV-like file used in [[PIXet EDU|&#039;&#039;&#039;PIXet EDU&#039;&#039;&#039;]] and [[PIXet#Clustering_plugin|&#039;&#039;&#039;Clustering plugin&#039;&#039;&#039;]] for saving histograms&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Files and directories of the Pixet and SDK]]&lt;br /&gt;
* [[Pixet_SDK|Pixet SDK overview]]&lt;br /&gt;
* [[PIXet|The PIXet program]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File:Plugin-tiff.png&amp;diff=1706</id>
		<title>File:Plugin-tiff.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File:Plugin-tiff.png&amp;diff=1706"/>
		<updated>2026-04-09T10:51:52Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=File:Plugin-hdf5.png&amp;diff=1705</id>
		<title>File:Plugin-hdf5.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=File:Plugin-hdf5.png&amp;diff=1705"/>
		<updated>2026-04-09T10:51:37Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1704</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1704"/>
		<updated>2026-04-07T14:00:24Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Multi-frame and data-driven with callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other callbacks ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand code parts examples --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Bindings of registering/unregistering general events:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    px.PXC_ACQEVENT_ACQ_FAILED = b&amp;quot;AcqFailed&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_STARTED = b&amp;quot;AcqMeasStarted&amp;quot;&lt;br /&gt;
    px.PXC_ACQEVENT_MEAS_FINISHED = b&amp;quot;AcqMeasFinished&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    #int pxcRegisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcRegisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcRegisterAcqEvent.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcUnregisterAcqEvent(unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData);&lt;br /&gt;
    px.pxcUnregisterAcqEvent.argtypes = [c_uint, c_char_p, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcUnregisterAcqEvent.restype = c_int&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Callback functions:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqStartCallback(acqCount, userData): # =============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqStart: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqFinCallback(acqCount, userData): # ===============================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqFinish: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def acqErrCallback(val, userData): # ====================================================&lt;br /&gt;
    print(f&amp;quot;***clb-acqErr: rc:{val-4294967295} usr:{userData}&amp;quot;)&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;    Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Registering/unregistering:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcRegisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED , acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcRegisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # do something usesfill ---------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_STARTED, acqStartCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (start) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_MEAS_FINISHED, acqFinCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (finish) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcUnregisterAcqEvent(devIdx, px.PXC_ACQEVENT_ACQ_FAILED, acqErrCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcUnregisterAcqEvent (failed) rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#pxcUnregisterAcqEvent|pxcUnregisterAcqEvent]]&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1703</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1703"/>
		<updated>2026-04-07T10:59:19Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Data-driven special settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1702</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1702"/>
		<updated>2026-04-07T09:11:37Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Python using Ctypes examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
Two callback types available:&lt;br /&gt;
# &#039;&#039;&#039;New frames&#039;&#039;&#039; measured: typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;New pixels&#039;&#039;&#039; measured: typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
# &#039;&#039;&#039;Other events&#039;&#039;&#039;: Use FrameMeasuredCallback too&lt;br /&gt;
&lt;br /&gt;
See:&lt;br /&gt;
* [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
* [[Binary_core_API#API_data-driven_measuring_functions|API data-driven measuring functions]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1701</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1701"/>
		<updated>2026-04-07T08:50:23Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Multi-frame with callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
See: [[Binary_core_API#Multiple_frames_using_callbacks|#Multiple frames using callbacks]]&lt;br /&gt;
&lt;br /&gt;
(Tpx3 specific functions used in example, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1700</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1700"/>
		<updated>2026-04-07T07:44:17Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Beam-hardenning correction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are corresponding.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1699</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1699"/>
		<updated>2026-04-02T16:52:40Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Beam-hardenning correction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it from Python.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The process:&#039;&#039;&#039;&lt;br /&gt;
# Add reference images (masks) for more material tihicknesses. Very good is from thinner than thinnest part of the object to thicker than whole the imaged object.&lt;br /&gt;
# Do the correction of the image&lt;br /&gt;
# Try do the non-correctible (deviceAndBH) pixels interpolation&lt;br /&gt;
# If failed, try interpolate only device bad pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful to:&#039;&#039;&#039;&lt;br /&gt;
* Reference images and images to correct are match.&lt;br /&gt;
:* Device used for imaging is same.&lt;br /&gt;
:* Xray source voltage, current, distance and optional filter is same.&lt;br /&gt;
:* Integrated times are true and in same units.&lt;br /&gt;
:* No other changes then integrated time and frames count.&lt;br /&gt;
&lt;br /&gt;
* Good data quality&lt;br /&gt;
:* High counts&lt;br /&gt;
:* No saturation in references.&lt;br /&gt;
:* Stable thickness and homogenous compound of references.&lt;br /&gt;
:* No saturation in interested area of image.&lt;br /&gt;
* Usesfull measuring mode/subframe. Use counts only.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tips:&#039;&#039;&#039;&lt;br /&gt;
* The &amp;quot;Acq time&amp;quot; metadata item from a .dsc file can be used to autodetect integrated time.&lt;br /&gt;
* If the bad pixels correction needed and the device not available, use the dummy device created using config of the device.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1698</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1698"/>
		<updated>2026-04-02T16:18:27Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Beam-hardenning correction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it prom Python.&lt;br /&gt;
&lt;br /&gt;
See:&lt;br /&gt;
* [[Devices_support#Dummy_device|Devices support: Dummy device]]&lt;br /&gt;
* [[#Beam_hardening_correction|#Beam hardening correction]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1697</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1697"/>
		<updated>2026-04-02T15:56:49Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Multi-frame and data-driven with callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Beam-hardenning correction ===&lt;br /&gt;
This feature isn&#039;t in the Python API. Ctypes is usesfull way to using it prom Python.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcAddBHMask(unsigned* data, unsigned size, double frameTime, double thickness);&lt;br /&gt;
    px.pxcAddBHMask.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, ctypes.c_double]&lt;br /&gt;
    px.pxcAddBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcBHMaskCount();&lt;br /&gt;
    px.pxcBHMaskCount.argtypes = []&lt;br /&gt;
    px.pxcBHMaskCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcRemoveBHMask(int index);&lt;br /&gt;
    px.pxcRemoveBHMask.argtypes = [c_int]&lt;br /&gt;
    px.pxcRemoveBHMask.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcApplyBHCorrection(unsigned* inData, unsigned size, double frameTime, double* outData);&lt;br /&gt;
    px.pxcApplyBHCorrection.argtypes = [POINTER(c_uint), c_uint, ctypes.c_double, POINTER(ctypes.c_double)]&lt;br /&gt;
    px.pxcApplyBHCorrection.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetBHBadPixelMatrix(unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceAndBHBadPixelMatrix(unsigned deviceIndex, unsigned char* badPixelMatrix, unsigned size);&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceAndBHBadPixelMatrix.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcInterpolateBadPixels(unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height);&lt;br /&gt;
    px.pxcInterpolateBadPixels.argtypes = [POINTER(c_char), POINTER(ctypes.c_double), c_uint, c_uint]&lt;br /&gt;
    px.pxcInterpolateBadPixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL, prefix=&amp;quot;&amp;quot;) -&amp;gt; int: # ====================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: &lt;br /&gt;
        s = buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;)&lt;br /&gt;
        print(f&amp;quot;{prefix}Err: &#039;{s.strip()}&#039;&amp;quot;)&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        spacesBeforeCnt = 0&lt;br /&gt;
        if name[0]==&amp;quot; &amp;quot;: spacesBeforeCnt = len(name) - len(name.lstrip())&lt;br /&gt;
        prefix = &#039; &#039; * spacesBeforeCnt&lt;br /&gt;
        if name[0]==&amp;quot;\t&amp;quot;: prefix=&amp;quot;\t&amp;quot;&lt;br /&gt;
        _showError(px, prefix)&lt;br /&gt;
&lt;br /&gt;
def loadFrameDataTxt(filePath, width, height):&lt;br /&gt;
    data = []&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
            for line in f:&lt;br /&gt;
                row = [int(x) for x in line.strip().split()]&lt;br /&gt;
                data.append(row)&lt;br /&gt;
        if len(data) != height or any(len(row) != width for row in data):&lt;br /&gt;
            raise ValueError(f&amp;quot;Data dimensions do not match: w:{len(data[0]) if data else -1} h:{len(data)} (expected w:{width} h:{height})&amp;quot;)&lt;br /&gt;
        return data&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error loading file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def saveFrameDataTxt(filePath, data, width, height): # ==================================&lt;br /&gt;
    try:&lt;br /&gt;
        with open(filePath, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
            for y in range(height):&lt;br /&gt;
                for x in range(width):&lt;br /&gt;
                    f.write(str(data[y*width + x]) + &amp;quot; &amp;quot;)&lt;br /&gt;
                f.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
            print(f&amp;quot;Saved:&#039;{filePath}&#039;&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error saving file:&#039;{filePath}&#039;: {e}&amp;quot;)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devPixels = -1&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t device that was origin of the data, bad pixels correction will not good)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    wid = devWidth.value&lt;br /&gt;
    hei = devHeight.value&lt;br /&gt;
    print(&amp;quot;Expected data dimmensions:&amp;quot;, wid, hei)&lt;br /&gt;
&lt;br /&gt;
    dataPath = os.path.join(thisPath, &amp;quot;../test-data&amp;quot;)&lt;br /&gt;
    fnamFilesRef = [&lt;br /&gt;
        [&amp;quot;BH0mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 0, 0.01*1000],  # timeIntegrated = singne frame * frames count [seconds]&lt;br /&gt;
        [&amp;quot;BH2mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 2, 0.01*1000], [&amp;quot;BH4mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 4, 0.01*1000],&lt;br /&gt;
        [&amp;quot;BH8mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 8, 0.01*1000], [&amp;quot;BH16mm_1000fr_0.01s_50kV_8mA.txt&amp;quot;, 16, 0.01*1000]&lt;br /&gt;
    ]&lt;br /&gt;
    # Be careful to reference images and images to correct are match.&lt;br /&gt;
    # - Integrated times are true and in same units&lt;br /&gt;
    # - Source voltage, current, distance and optional filter is same&lt;br /&gt;
&lt;br /&gt;
    for fileName, thickness, timeIntegrated in fnamFilesRef:&lt;br /&gt;
        print(f&amp;quot;    Add file:&#039;{fileName}&#039;, tim:{timeIntegrated} s, thc:{thickness} mm&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is None: continue&lt;br /&gt;
        flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
        dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
        a = sum(flatData)/len(flatData)&lt;br /&gt;
        print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
        rc = px.pxcAddBHMask(dataArray, len(flatData), timeIntegrated, thickness)&lt;br /&gt;
        _testShowError(&amp;quot;pxcAddBHMask&amp;quot;, rc)&lt;br /&gt;
    print(&amp;quot;BH masks added:&amp;quot;, px.pxcBHMaskCount())&lt;br /&gt;
    &lt;br /&gt;
    fnamFilesData = [&lt;br /&gt;
        [&amp;quot;test_1fr0.0993333s50kev8mA.txt&amp;quot;, 0.0993333], [&amp;quot;test_1000fr0.01s50kev8mA.txt&amp;quot;, 1000*0.01]&lt;br /&gt;
    ]&lt;br /&gt;
    badPixelsArr = (c_char * devPixels)()&lt;br /&gt;
    &lt;br /&gt;
    for fileName, timeIntegrated in fnamFilesData:&lt;br /&gt;
        print(f&amp;quot;    File:&#039;{fileName}&#039; time sum:{timeIntegrated} s&amp;quot;)&lt;br /&gt;
        data = loadFrameDataTxt(os.path.join(dataPath, fileName), wid, hei)&lt;br /&gt;
        if data is not None:&lt;br /&gt;
            flatData = [pixel for row in data for pixel in row]&lt;br /&gt;
            dataArray = (c_uint * len(flatData))(*flatData)&lt;br /&gt;
            outDataArray = (ctypes.c_double * len(flatData))()&lt;br /&gt;
            a = sum(flatData)/len(flatData)&lt;br /&gt;
            print(&amp;quot;    average:&amp;quot;, a, &amp;quot;Warning too low counts (&amp;gt;50k recommended)&amp;quot; if a&amp;lt;50000 else &amp;quot;&amp;quot;)&lt;br /&gt;
            rc = px.pxcApplyBHCorrection(dataArray, len(flatData), timeIntegrated, outDataArray)&lt;br /&gt;
            _testShowError(&amp;quot;pxcApplyBHCorrection&amp;quot;, rc)&lt;br /&gt;
            # dataArray now containing BH corrected data, but with bad pixels&lt;br /&gt;
            rc = px.pxcGetDeviceAndBHBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
            _testShowError(&amp;quot;    pxcGetDeviceAndBHBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
            cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)    &lt;br /&gt;
            print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
            rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
            # badPixelsArr now containing device bad pixels and pixels that was has data useless for BHC&lt;br /&gt;
            _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
            if rc==-13: # Too many bad pixels - try use only device bad pixels without BH useless pixels&lt;br /&gt;
                print(&amp;quot;    Too many bad pixels - try use only device bad pixels&amp;quot;)&lt;br /&gt;
                rc = px.pxcGetDeviceBadPixelMatrix(devIdx, badPixelsArr, devPixels)&lt;br /&gt;
                print(&amp;quot;    pxcGetDeviceBadPixelMatrix rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcGetDeviceBadPixelMatrix&amp;quot;, rc)&lt;br /&gt;
                cnt = sum(1 for i in range(devPixels) if badPixelsArr[i] != b&#039;\0&#039;)&lt;br /&gt;
                print(&amp;quot;    Bad pixels:&amp;quot;, cnt)&lt;br /&gt;
                rc = px.pxcInterpolateBadPixels(badPixelsArr, outDataArray, wid, hei)&lt;br /&gt;
                print(&amp;quot;    pxcInterpolateBadPixels rc:&amp;quot;, rc)&lt;br /&gt;
                _testShowError(&amp;quot;    pxcInterpolateBadPixels&amp;quot;, rc)&lt;br /&gt;
                if rc==-13:&lt;br /&gt;
                    print(&amp;quot;    Too many bad pixels - Is the device configured properly?&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
            opath = os.path.join(dataPath, fileName.replace(&amp;quot;.txt&amp;quot;, &amp;quot;-BHC.txt&amp;quot;))&lt;br /&gt;
            saveFrameDataTxt(opath, outDataArray, wid, hei)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;    (no data readed)&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1696</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1696"/>
		<updated>2026-03-31T16:22:24Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Python using Ctypes examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
Tip: Copy definition line from pxcapi.h to the bindings section as comment and start writing binding below it. The copilot usually completes it correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-package&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0: doSomeFatalErrorHandling(rc)&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT) # set the operation mode&lt;br /&gt;
print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # Singlechip default&lt;br /&gt;
frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
&lt;br /&gt;
# Do something with the data&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
rc = px.pxcExit()&lt;br /&gt;
print(&amp;quot;pxcExit rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1695</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1695"/>
		<updated>2026-03-31T15:46:45Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Multi-frame with callback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame and data-driven with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
class clTpx3Pixel(ctypes.Structure):&lt;br /&gt;
    _fields_ = [(&amp;quot;toa&amp;quot;, ctypes.c_double), (&amp;quot;tot&amp;quot;, ctypes.c_float), (&amp;quot;index&amp;quot;, c_uint)]&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.argtypes = [c_uint, ctypes.c_double, c_char_p, c_uint, ctypes.CFUNCTYPE(None, c_void_p, c_char_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureTpx3DataDrivenMode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.argtypes = [c_uint, POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3PixelsCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.argtypes = [c_uint, POINTER(clTpx3Pixel), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredTpx3Pixels.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
def _testShowError(name, rc, text=&amp;quot;&amp;quot;): # ================================================&lt;br /&gt;
    if rc &amp;lt; 0:&lt;br /&gt;
        print(f&amp;quot;{name} failed - rc:{rc}&amp;quot;, text)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***clb-frame: acqCount:{acqCount} usr:{userData}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(devIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredFrameTpx3&amp;quot;, rc, f&amp;quot;size:{size.value}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
tpx3PixelsBuffSize = 1000000&lt;br /&gt;
tpx3PixelsBuff = (clTpx3Pixel * tpx3PixelsBuffSize)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
PixelsMeasuredCllback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_char_p)&lt;br /&gt;
&lt;br /&gt;
@PixelsMeasuredCllback&lt;br /&gt;
def pixelsMeasuredCallback(eventData, userData): # ======================================&lt;br /&gt;
    tag = userData.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;) if userData else None&lt;br /&gt;
    print(f&amp;quot;***clb-pixels: eventData:{eventData} usr:{tag}&amp;quot;)&lt;br /&gt;
    pxCnt = c_uint()&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3PixelsCount(devIdx, byref(pxCnt))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3PixelsCount&amp;quot;, rc, f&amp;quot;pxCnt:{pxCnt}&amp;quot;)&lt;br /&gt;
    print(&amp;quot;    Pixels count:&amp;quot;, pxCnt.value)&lt;br /&gt;
&lt;br /&gt;
    pixelsToRead = min(pxCnt.value, tpx3PixelsBuffSize)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredTpx3Pixels(devIdx, tpx3PixelsBuff, byref(c_uint(pixelsToRead)))&lt;br /&gt;
    _testShowError(&amp;quot;    pxcGetMeasuredTpx3Pixels&amp;quot;, rc, f&amp;quot;pixelsToRead:{pixelsToRead}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    totMin = 1e10&lt;br /&gt;
    totMax = -1&lt;br /&gt;
    toaMin = 1e100&lt;br /&gt;
    toaMax = -1&lt;br /&gt;
    for n in range(pixelsToRead):&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;lt; totMin: totMin = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].tot &amp;gt; totMax: totMax = tpx3PixelsBuff[n].tot&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;lt; toaMin: toaMin = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if tpx3PixelsBuff[n].toa &amp;gt; toaMax: toaMax = tpx3PixelsBuff[n].toa&lt;br /&gt;
        if n&amp;lt;10:&lt;br /&gt;
            print(f&amp;quot;    - Pixel {n}: index:{tpx3PixelsBuff[n].index} tot:{tpx3PixelsBuff[n].tot} toa:{tpx3PixelsBuff[n].toa/1e9} s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Tot min/max:&amp;quot;, totMin, totMax, &amp;quot;Toa min/max:&amp;quot;, toaMin, toaMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    devIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, devIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(devIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(devIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(devIdx, px.OPM_TOATOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    # userData can be used to transfer device info to callback in multi-device setup &lt;br /&gt;
    user_tag = ctypes.create_string_buffer(name_buf.value) #f&amp;quot;devIdx:{devIdx}&amp;quot;.encode(&amp;quot;utf-8&amp;quot;))&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureTpx3DataDrivenMode(devIdx, 10.0, None, 0, pixelsMeasuredCallback, user_tag)&lt;br /&gt;
    print(&amp;quot;pxcMeasureTpx3DataDrivenMode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureTpx3DataDrivenMode failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1694</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1694"/>
		<updated>2026-03-31T10:47:23Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Python using Ctypes example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes examples ==&lt;br /&gt;
(Inspirations if you really want to experience such harakiri)&lt;br /&gt;
&lt;br /&gt;
=== Simple one frame measurement ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Multi-frame with callback ===&lt;br /&gt;
(Tpx3 specific functions used, must be changed for other chip types)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, c_void_p, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;start...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL: # =======================================&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None: # ===========================================&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureMultipleFramesWithCallback(unsigned deviceIndex, unsigned frameCount, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    px.pxcMeasureMultipleFramesWithCallback.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameCount(unsigned deviceIndex);&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.argtypes = [c_uint]&lt;br /&gt;
    px.pxcGetMeasuredFrameCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetMeasuredFrameTpx3(unsigned deviceIndex, unsigned frameIndex, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size);&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.argtypes = [c_uint, c_uint, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetMeasuredFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int: # ===============================================&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
devPixels = 65536 # singlechip default&lt;br /&gt;
frameToaITot = None #(ctypes.c_double * devPixels)()&lt;br /&gt;
frameTotEvent = None #(ctypes.c_ushort * devPixels)()&lt;br /&gt;
&lt;br /&gt;
# typedef void (*FrameMeasuredCallback)(intptr_t acqCount, intptr_t userData);&lt;br /&gt;
FrameMeasuredCallback = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)&lt;br /&gt;
&lt;br /&gt;
@FrameMeasuredCallback&lt;br /&gt;
def frameMeasuredCallback(acqCount, userData): # ========================================&lt;br /&gt;
    print(f&amp;quot;***callback: acqCount:{acqCount}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    size = ctypes.c_uint(devPixels)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcGetMeasuredFrameTpx3(pxIdx, acqCount-1, frameToaITot, frameTotEvent, ctypes.byref(size))&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        print(&amp;quot;    pxcGetMeasuredFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;    Hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
# ---------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc, end=&amp;quot; &amp;quot;)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)\n&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
        frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
        frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    #px.pxcMeasureMultipleFramesWithCallback.argtypes = [c_uint, c_uint, ctypes.c_double, c_uint, ctypes.CFUNCTYPE(None, c_uint, c_uint, c_void_p), c_void_p]&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureMultipleFramesWithCallback(pxIdx, 5, 1.0, 0, frameMeasuredCallback, None)&lt;br /&gt;
    print(&amp;quot;pxcMeasureMultipleFramesWithCallback rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureMultipleFramesWithCallback failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1693</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1693"/>
		<updated>2026-03-27T17:17:30Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* API frame-data processing functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, uneven distribution of irradiation, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&lt;br /&gt;
&lt;br /&gt;
Process summary:&lt;br /&gt;
# Measure the correction data to be used in BHC&lt;br /&gt;
# Measure the main data&lt;br /&gt;
# Apply the Beam hardenning correction&lt;br /&gt;
# Apply the Bad pixel correction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
During BHC, pixels are found that did not work properly. For example, defective, saturated in the main image, saturated in some of the reference images, or are unusable for correction for another reason.&amp;lt;br&amp;gt;&lt;br /&gt;
If they do not form continuous areas, they can be compensated by interpolation from the surroundings,&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1692</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1692"/>
		<updated>2026-03-27T16:58:25Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* API frame-data processing functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1691</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1691"/>
		<updated>2026-03-27T16:55:09Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Interpolating of bad pixels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the device&#039;s matrix of user-masked pixels (masked = 1, not masked = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* userMaskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| userMaskMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1690</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1690"/>
		<updated>2026-03-27T16:35:50Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains:&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1689</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1689"/>
		<updated>2026-03-27T16:34:44Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
See also: [[#Interpolating_of_bad_pixels|#Interpolating of bad pixels]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1688</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1688"/>
		<updated>2026-03-27T15:49:24Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1687</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1687"/>
		<updated>2026-03-27T15:43:50Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 there are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked.&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared without lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* pixCfgData, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixCfgData – pixel configuration data - TPXPixCfg, MPX3PixCfg, TPX3PixCfg, ... encoded bytes&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the Device Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – matrix setting which pixels are masked (PXC_PIXEL_MASKED = 0) and not masked (PXC_PIXEL_UNMASKED = 1)&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetUserMaskMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the User Mask Matrix.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcClearUserMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Clears the User Mask (unmasks all pixels in user mask).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1686</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1686"/>
		<updated>2026-03-27T14:25:28Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: Undo revision 1685 by HudecekP (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared before lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – pixel mask matrix. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned byteSize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1685</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1685"/>
		<updated>2026-03-27T13:45:04Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Pixel matrix and masks management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
	<entry>
		<id>https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1684</id>
		<title>Binary core API</title>
		<link rel="alternate" type="text/html" href="https://wiki.advacam.cz/index.php?title=Binary_core_API&amp;diff=1684"/>
		<updated>2026-03-27T13:42:15Z</updated>

		<summary type="html">&lt;p&gt;HudecekP: /* Parameter Get/Set functions (direct) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Core/basic binary (C/C++) API introduction =&lt;br /&gt;
&lt;br /&gt;
This API is part of the Advacam&#039;s [[Pixet SDK]] and allows access to functions of the Pixet Core.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The binary API parts are:&lt;br /&gt;
# &#039;&#039;&#039;Binary core/basic API&#039;&#039;&#039; (this document)&lt;br /&gt;
# [[Binary_Clustering_API|Binary clustering API]]&lt;br /&gt;
# [[Binary_Spectral_Imaging_API|Binary spectral imaging API]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[Pixet SDK|Pixet SDK overview]]&lt;br /&gt;
&lt;br /&gt;
== Usage overview ==&lt;br /&gt;
* Settings of the device&lt;br /&gt;
* Getting information about the device&lt;br /&gt;
* Single-frame measurement&lt;br /&gt;
* Multi-frame measurement&lt;br /&gt;
* Continuous frame measurement (endless repeats and without dead time on some devices, Mpx3 and Tpx2 for example) &lt;br /&gt;
* Data-driven (pixel mode) measurement (Tpx3 only)&lt;br /&gt;
* Synchronized measurement&lt;br /&gt;
* TDI imaging - Scanning linearly moving objects, for example on a conveyor belt.&lt;br /&gt;
* Basic image bad pixel correction&lt;br /&gt;
* Beam hardening correction (Xray imaging has a very non-linear relationship between the thickness of the material and the intensity of the transmitted radiation. First, low-energy radiation is captured, followed by components that are significantly more penetrating.)&lt;br /&gt;
&lt;br /&gt;
== Libraries ==&lt;br /&gt;
The core API with the &#039;&#039;&#039;pxcore library&#039;&#039;&#039;, allowing basic measurements and device settings.&amp;lt;br&amp;gt;&lt;br /&gt;
Files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using on Windows (compile time only)&lt;br /&gt;
* &#039;&#039;&#039;common.h&#039;&#039;&#039; common file defining basic types, constatns and usefull macros. It&#039;s not necessary, but it can be useful.&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
This API requires computer with x86 compatible architecture or ARM with memory management features (no small MCU), 64bit Windows or Linux and connected some Advacam hardware with imaging chip. Medipix3, Timepix, Timepix2, Timepix3, etc. Some functions are universal for all hardwares (pxcInitialize, pxcGetDeviceName, etc), some is specialized for only one chip type (pxcMeasureSingleFrameTpx3 is Timepix3 only).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Specialized functions have names with chip type included:&#039;&#039;&#039;&lt;br /&gt;
* pxcSet&#039;&#039;&#039;Timepix&#039;&#039;&#039;CalibrationEnabled – Timepix only (no Timepix3)&lt;br /&gt;
* pxcMeasure&#039;&#039;&#039;Tpx3&#039;&#039;&#039;DataDrivenMode – Timepix3 only&lt;br /&gt;
* pxcMeasureSingleFrame&#039;&#039;&#039;Mpx3&#039;&#039;&#039; – Medipix3 only&lt;br /&gt;
&lt;br /&gt;
The attempt to use the function if compatible hardware (in initialized state) not present, end with error.&amp;lt;br&amp;gt;&lt;br /&gt;
Return code is &#039;&#039;&#039;PXCERR_UNEXPECTED_ERROR&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
All the API functions have heads in pxcapi.h, implemented for Windows in the pxcore.dll and for linking must use the pxcore.lib in the linker settings. Implementation for Linux is in the libcore.so.&amp;lt;br&amp;gt;&lt;br /&gt;
Compiled program need the pixet.ini file with proper hwlibs list inside, necessary hardware dll files (eq minipix.dll for Minipixes), optional special files (eq zestwpx.bit for Widepixes), subdirectory “factory” with default config files for all present imaging devices (eq MiniPIX-I08-W0060.xml) and the Pixet core will create subdirectory “configs” to save changed configs on exit.&amp;lt;br&amp;gt;&lt;br /&gt;
See &#039;&#039;&#039;[[#The Pixet core, additional libraries and other files|The Pixet core, additional libraries and other files]]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Usually, for build, just set the compiler to use 64bit and the linker to use the pxcore.lib file.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In Microsoft visual studio, while creating the C++ CLR project, it is also necessary to insert the use of WIN32 definition into the project settings (C/C++ / Preprocessor / Preprocessor definitions):&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:VisualStudio-PrjSettings.png|frame|none|alt=Visual Studio Project Settings|Visual Studio Project Settings]]&lt;br /&gt;
&lt;br /&gt;
=== The Pixet core, additional libraries and other files ===&lt;br /&gt;
Main files:&lt;br /&gt;
* &#039;&#039;&#039;pxcapi.h&#039;&#039;&#039; API header file for importing to C/C++&lt;br /&gt;
* &#039;&#039;&#039;pxcore.dll&#039;&#039;&#039; or &#039;&#039;&#039;pxcore.so&#039;&#039;&#039; binary libraries for Windows or Linux&lt;br /&gt;
* &#039;&#039;&#039;pxcore.lib&#039;&#039;&#039; static linging file for easier using in C/C++ on Windows&lt;br /&gt;
&lt;br /&gt;
And need some auxiliary files and directories:&amp;lt;br&amp;gt;&lt;br /&gt;
* See [[Pixet SDK#Auxilliary files|Pixet SDK: Auxilliary files]]&lt;br /&gt;
* See [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
&lt;br /&gt;
==== Where to get these files? ====&lt;br /&gt;
: All need files except  XML configs are located in the zip file with name like us:&lt;br /&gt;
::&#039;&#039;&#039;API_PIXet_Pro_1.8.2_Windows_x86_64.zip&#039;&#039;&#039;&lt;br /&gt;
::&#039;&#039;&#039;Download:&#039;&#039;&#039; [https://advacam.com/downloads/ Advacam download page]&amp;lt;br&amp;gt;&lt;br /&gt;
: Be careful about the correct libraries, we supply&lt;br /&gt;
:* Windows-x86-64b&lt;br /&gt;
:* Linux-x86-64b&lt;br /&gt;
:* Linux-ARM-32b&lt;br /&gt;
:* Linux-ARM-64b&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
:And all files except LIB files for Windows compilation are located in the Pixet directory:&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Files-usable-for-SDK-in-Pixet.png|frame|none|alt=All files except LIB files for Windows compilation are located in the Pixet directory|All files except LIB files for Windows compilation are located in the Pixet directory]]&lt;br /&gt;
&lt;br /&gt;
==== Example of the project directory ====&lt;br /&gt;
[[File:Example-project-dirrectory.png|frame|right|alt=Example of the project dirrectory|Example of the project dirrectory]]&lt;br /&gt;
On the right is a screenshot of the Windows CLR APP project directory in Visual Studio that uses Minipix Tpx3. The marked files were copied from the Advacam SDK and the &amp;quot;factory&amp;quot; directory contains the configuration &lt;br /&gt;
XML file for the device. It is important that the name is complete, eg MiniPIX-I08-W0060.xml. This file will be used on first launch.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The directory &amp;quot;configs&amp;quot; is created when Pixet core is terminated and contains a configuration XML file with saved current settings. This file will be used on each subsequent startup and updated on each subsequent exit.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The &amp;quot;logs&amp;quot; directory is created when Pixet core is started for the first time and contains LOG files from device activity and backups of these files for the last 10 starts.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Contents of the pixet.ini file: &lt;br /&gt;
 [hwlibs]&lt;br /&gt;
 minipix.dll&lt;br /&gt;
&lt;br /&gt;
(x64, Myform... and TPx3-1... are from the MS Visual studio project)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Don&#039;t forget to set up WIN32 and pxcore.lib in the project settings as described in the parent chapter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Tip: How to create the Windows CLR APP:&amp;lt;br&amp;gt;&lt;br /&gt;
[https://social.msdn.microsoft.com/Forums/windows/en-US/a9529502-6304-4aa6-90ee-0757ab258d87/create-c-windows-forms-application-in-visual-studio-2017?forum=winforms MSDN:create-c-windows-forms-application-in-visual-studio-2017]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example of the minimalistic program directory ====&lt;br /&gt;
[[File:dirrectory-minimalistic-api-prg.png|frame|center|alt=Example of the minimalistic project dirrectory|Example of the minimalistic project dirrectory]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Hints =&lt;br /&gt;
Some hints how to avoid complications when using our API.&lt;br /&gt;
&lt;br /&gt;
== Error handling ==&lt;br /&gt;
Always use error handling.&lt;br /&gt;
* Level 1: Allways check the return code&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; endl; return rc;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
* Level 2: and show error messages&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int rc = pxcMeasureContinuous(devIdx, 10, 0.08);&lt;br /&gt;
if (rc!=0) {&lt;br /&gt;
   char buff[500];&lt;br /&gt;
   pxcGetLastError(buff, 500);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;pxcMeasureContinuous: Error code:&amp;quot; &amp;lt;&amp;lt; rc &amp;lt;&amp;lt; &amp;quot; msg:&amp;quot; &amp;lt;&amp;lt; buff &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Device configuration ==&lt;br /&gt;
For proper operation, it is necessary that the device is correctly configured. There are quite a lot of settings and they all affect the measurement or other behavior of the device. During initialization, the configuration that was previously saved when exiting is used. &amp;lt;br&amp;gt;&lt;br /&gt;
Details: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
&lt;br /&gt;
Be aware of the &#039;&#039;&#039;differences between the default settings of the Pixet program and the API&#039;&#039;&#039; package:&lt;br /&gt;
* Pixet installed from the installation flash that came with the device contains the factory config for your device. The device will be properly configured at first start.&lt;br /&gt;
* PIxet uses AppDataDir. So if you start one Pixet, close it, and then start another one that is installed elsewhere, it will use the settings saved when closing the first one.&lt;br /&gt;
* The API package is set to use the configs and factory subdirectories. Configurations in all projects are independent. If you do not copy the factory config to the factory, the default settings will not be correct and, with the exception of Minipix, even the Load factory config function will not work. Also, the settings made in Pixet will not be reflected in your project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solutions:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Use &#039;&#039;&#039;global factory directory&#039;&#039;&#039; on Your computer, like as C:/integration/advadam/factory-configs copy all factory configs to it, set it in all instances of Pixet and API-using programs, using &#039;&#039;&#039;FactoryDir=&#039;&#039;&#039; in it&#039;s &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; files. All programs always starts with &#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039; and next configure every need to be changed (typicaly operation mode).&lt;br /&gt;
: Very usefull if developing software for industry integration and using more devices.&lt;br /&gt;
* &#039;&#039;&#039;Copy settings&#039;&#039;&#039; from the Pixet: Optimize all settings of the device in the Pixet program, exit Pixet and copy final config from AppDataDir/configs to the configs of Your project.&lt;br /&gt;
: Usesfull if You developping one project with one device and if the project workflow can be manually do in the Pixet.&lt;br /&gt;
* &#039;&#039;&#039;Load configuration&#039;&#039;&#039; using pxcLoadDeviceConfiguration from the AppDataDir or load copy of this file.&lt;br /&gt;
: Practically the same using as the previous solution.&lt;br /&gt;
* Set the &#039;&#039;&#039;UseAppDataDir=true&#039;&#039;&#039; in the &#039;&#039;&#039;pixet.ini&#039;&#039;&#039; in Your project. It will share all configurations with the Pixet program.&lt;br /&gt;
: Note the factory directory is not default/automatic subdirectory of the AppDataDir.&lt;br /&gt;
: Usesfull for simple tests, but it leads to interactions between projects, where they change each other&#039;s settings.&lt;br /&gt;
&lt;br /&gt;
Some example&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;pxcGetDevicesCount: %d (&amp;gt;=0 is count of devs)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc&amp;lt;1) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcLoadFactoryConfig(0);&lt;br /&gt;
     printf(&amp;quot;pxcLoadFactoryConfig: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0 to ToA+ToT&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
&lt;br /&gt;
     rc = pxcSetTimepix3CalibrationEnabled(0, true); // enable calibration ToT in frames to Energy [keV]&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3CalibrationEnabled: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
     // do not change threshold if using calibration (ToT calibrated only for default threshold)&lt;br /&gt;
&lt;br /&gt;
     // do some measurements here&lt;br /&gt;
&lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     if (rc!=0) return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Note&lt;br /&gt;
: Always make sure that the factory config is available in the expected location and with the correct name for automatic use.&lt;br /&gt;
: See: [[Files_and_directories_of_the_Pixet_and_SDK#Configuration_XML_files|Files and directories of the Pixet and SDK: Configuration XML files]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Thus section is under construction)&lt;br /&gt;
&lt;br /&gt;
= Some examples =&lt;br /&gt;
&lt;br /&gt;
== Simple C commandline example and build ==&lt;br /&gt;
See the measurement basics to understand examples:&lt;br /&gt;
* [[Binary_core_API#Frame-based_basic_measurement_flow|Frame-based basic measurement flow]]&lt;br /&gt;
* [[Binary_core_API#Data-driven_basic_measurement_flow|Data-driven basic measurement flow]]&lt;br /&gt;
&lt;br /&gt;
=== Example code ===&lt;br /&gt;
----&lt;br /&gt;
This is simple example of commandline C program, whitch initializes the Pixet core and device, sets it&#039;s operation mode, measures single frame, saves the frame to some files and deinitializes the Pixet core with all the connected devices.&amp;lt;br&amp;gt;&lt;br /&gt;
(Timepix3 only)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     int rc; // return code&lt;br /&gt;
     &lt;br /&gt;
     printf(&amp;quot;Initializing...\n&amp;quot;);&lt;br /&gt;
     rc = pxcInitialize();&lt;br /&gt;
     printf(&amp;quot;pxcInitialize: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT); // sets OPM of device with index 0&lt;br /&gt;
     printf(&amp;quot;pxcSetTimepix3Mode: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcMeasureMultipleFrames(deviceIndex, frameCount, acqTime, triggerSettings);&lt;br /&gt;
     rc = pxcMeasureMultipleFrames(0, 3, 1, PXC_TRG_NO);&lt;br /&gt;
     printf(&amp;quot;pxcMeasureMultipleFrames: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     // pxcSaveMeasuredFrame(deviceIndex, frameLastIndex, filename);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 0, &amp;quot;testImg0.png&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 0: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 1, &amp;quot;testImg1.txt&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 1: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     rc = pxcSaveMeasuredFrame(0, 2, &amp;quot;testImg2.pbf&amp;quot;);&lt;br /&gt;
     printf(&amp;quot;pxcSaveMeasuredFrame 2: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
     &lt;br /&gt;
     rc = pxcExit();&lt;br /&gt;
     printf(&amp;quot;pxcExit: %d (0 is OK)\n&amp;quot;, rc);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: If You want test it in device other than Timepix3, You can comment lines with pxcSetTimepix3Mode. But then it is not clear what will be measured.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building using cmake on Windows with Visual Studio installed ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Example of CMakeLists.txt&#039;&#039;&#039; file for compiling this using cmake (C++ file is named &amp;quot;&#039;&#039;&#039;minipix1.cpp&#039;&#039;&#039;&amp;quot;):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
 cmake_minimum_required(VERSION 3.10)&lt;br /&gt;
 project(minipix1)&lt;br /&gt;
 &lt;br /&gt;
 # include_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 # link_directories(${CMAKE_SOURCE_DIR})&lt;br /&gt;
 add_library(pxcore SHARED IMPORTED)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_LOCATION &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.dll&amp;quot;)&lt;br /&gt;
 set_property(TARGET pxcore PROPERTY IMPORTED_IMPLIB  &amp;quot;${CMAKE_SOURCE_DIR}/pxcore.lib&amp;quot;)&lt;br /&gt;
 add_executable(minipix1 minipix1.cpp)&lt;br /&gt;
 target_link_libraries(minipix1 pxcore)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example of the Cmake building script:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 rmdir /s /q build&lt;br /&gt;
 mkdir build&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. &lt;br /&gt;
 &lt;br /&gt;
 msbuild /P:Configuration=Release ALL_BUILD.vcxproj &lt;br /&gt;
 &lt;br /&gt;
 cd .. &lt;br /&gt;
 copy pxcore.dll build\Release\pxcore.dll&lt;br /&gt;
 copy minipix.dll build\Release\minipix.dll&lt;br /&gt;
 copy pixet.ini build\Release\pixet.ini&lt;br /&gt;
 echo build\Release\minipix1.exe &amp;gt; run.cmd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
User can finally run the &#039;&#039;&#039;run.cmd&#039;&#039;&#039; to run the program.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Building on Linux using GCC ===&lt;br /&gt;
----&lt;br /&gt;
Example build.sh:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 gcc -o build-out minipix1.cpp -Wno-write-strings -L. -lpxcore  -ldl -lm -lc -g&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example run.sh to run the output executable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 LD_LIBRARY_PATH=. ./build-out&lt;br /&gt;
 # run last compiled example&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Troubleshooting:&lt;br /&gt;
* Be careful of &#039;&#039;&#039;library, platform and system compatibility&#039;&#039;&#039;.&lt;br /&gt;
: That is, 32/64 bit, Intel vs ARM architecture and the use of unusual Linux distributions.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;skipping incompatible ./libpxcore.so when searching for -lpxcore&#039;&#039;&#039;&lt;br /&gt;
* Be careful of &#039;&#039;&#039;gcc and it&#039;s libraries versions&#039;&#039;&#039;.&lt;br /&gt;
: If too old, some errors will occur.&lt;br /&gt;
: Example error message: &#039;&#039;&#039;undefined reference to symbol &#039;_Znam@@GLIBCXX_3.4&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== C++ Windows CLR examples ==&lt;br /&gt;
=== AdvacamAPIexamples package ===&lt;br /&gt;
This is the package of example apps for all device types.&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/AdvacamAPIexamples.rar&lt;br /&gt;
: (MS Visual Studio 2017 Solution with C++ projects of Windows CLR programs)&lt;br /&gt;
&lt;br /&gt;
=== Examples using std future ===&lt;br /&gt;
This is the package of 2 small examples with &#039;&#039;&#039;paralell measuring&#039;&#039;&#039; at more devices, using &#039;&#039;&#039;std::future&#039;&#039;&#039;. Timepix3 only.&lt;br /&gt;
: One is Windows &#039;&#039;&#039;CLR APP&#039;&#039;&#039;, second is &#039;&#039;&#039;commandline&#039;&#039;&#039;&lt;br /&gt;
; Link&lt;br /&gt;
: https://advacam.com/examples/ExamplesUsingFuture.rar&lt;br /&gt;
: (MS Visual Studio 2022 Solution with 2 C++ projects)&lt;br /&gt;
&lt;br /&gt;
== C# examples ==&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
* Use the release/64 bit configuration&lt;br /&gt;
* Functions that have optional parameters in pxcapi.h (for example pxcInitialize) must be declared with all parameters and then called, for example, with zeros.&lt;br /&gt;
* The working directory is directory with the exe file. Typically project\bin\Release. Copy pixet.ini and other auxilliary files here.&lt;br /&gt;
* In the MS Visual studio 2022 (and may be other), project first not working. You must click Properties, change .NET version to old, save it, change .NET version back to actual and save. Now project can work.&lt;br /&gt;
* Our API can also be used to produce cross-platform software. In that case, be careful about the correct libraries, we supply Windows-x86-64b / Linux-x86-64b / Linux-ARM-32b / Linux-ARM-64b.&lt;br /&gt;
&lt;br /&gt;
=== Dummy C# commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
        static void Main(string[] args) {&lt;br /&gt;
            int rc;&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize ...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize(); &lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} (0 is OK)&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            rc = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}\n&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            if (rc &amp;gt; 0) {&lt;br /&gt;
                // do something now&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D} Press any key to exit&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
            Console.ReadKey();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some more complex C# imports for inspiration ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceChipID(UInt32 deviceIndex, UInt32 chipIndex, StringBuilder chipIDBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcGetDeviceDimensions(UInt32 deviceIndex, ref UInt32 width, ref UInt32 height);&lt;br /&gt;
&lt;br /&gt;
 [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
 public static extern int pxcMeasureSingleFrameTpx3(UInt32 deviceIndex, double frameTime, [Out] double[] frameToaITot, [Out] UInt16[] frameTotEvent, ref UInt32 size, UInt32 trgStg = 0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C# data-driven commandline example ===&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
&lt;br /&gt;
namespace ConsoleApp1 {&lt;br /&gt;
    class Program {&lt;br /&gt;
        //public static extern int pxcInitialize(Int32 a, UInt64 b); // before 1.8.5&lt;br /&gt;
        //PXCAPI int pxcInitialize(const char *iniFile=&amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
        public static extern int pxcInitialize(string iniFile = &amp;quot;pixet.ini&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcExit();&lt;br /&gt;
&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDevicesCount();&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetLastError(char* errorMsgBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetLastError(StringBuilder errorMsgBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetDeviceName(unsigned deviceIndex, char* nameBuffer, unsigned size);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetDeviceName(UInt32 deviceIndex, StringBuilder nameBuffer, UInt32 size);&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcMeasureTpx3DataDrivenMode(unsigned deviceIndex, double measTime, const char* fileName, unsigned trgStg = PXC_TRG_NO, AcqEventFunc callback = 0, intptr_t userData = 0);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcMeasureTpx3DataDrivenMode(UInt32 deviceIndex, double measTime, string fileName, UInt32 trgStg = 0, IntPtr callback = default, IntPtr userData = default);&lt;br /&gt;
        &lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3PixelsCount(unsigned deviceIndex, unsigned* pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3PixelsCount(UInt32 deviceIndex, out UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        // typedef struct _Tpx3Pixel {double toa; float tot; unsigned int index;} Tpx3Pixel;&lt;br /&gt;
        [StructLayout(LayoutKind.Sequential)]&lt;br /&gt;
        public struct Tpx3Pixel&lt;br /&gt;
        {&lt;br /&gt;
            public double toa;&lt;br /&gt;
            public float tot;&lt;br /&gt;
            public UInt32 index;&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //PXCAPI int pxcGetMeasuredTpx3Pixels(unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount);&lt;br /&gt;
        [DllImport(&amp;quot;pxcore.dll&amp;quot;, CallingConvention = CallingConvention.Cdecl)]&lt;br /&gt;
        public static extern int pxcGetMeasuredTpx3Pixels(UInt32 deviceIndex, [Out] Tpx3Pixel[] pixels, UInt32 pixelCount);&lt;br /&gt;
&lt;br /&gt;
        const UInt32 pixelBuffSize = 1000000;&lt;br /&gt;
        static Tpx3Pixel[] pixelBuffer = new Tpx3Pixel[pixelBuffSize];&lt;br /&gt;
&lt;br /&gt;
        //typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
        public delegate void AcqEventFunc(IntPtr eventData, IntPtr userData);&lt;br /&gt;
        &lt;br /&gt;
        public static void AcqEventCallback(IntPtr eventData, IntPtr userData)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;*** AcqEventCallback evd={0} ud={1}&amp;quot;, eventData, userData.ToInt64());&lt;br /&gt;
            UInt32 pixelCount;&lt;br /&gt;
            int rc = pxcGetMeasuredTpx3PixelsCount(0, out pixelCount);&lt;br /&gt;
            Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3PixelsCount rc={0:D} pixelCount={1} {2}&amp;quot;, rc, pixelCount, pixelCount&amp;gt;pixelBuffSize ? &amp;quot;(data truncated)&amp;quot; : &amp;quot;&amp;quot;);&lt;br /&gt;
            if (pixelCount &amp;gt; 0)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetMeasuredTpx3Pixels(0, pixelBuffer, (pixelCount&amp;lt;pixelBuffSize) ? pixelCount : pixelBuffSize);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    pxcGetMeasuredTpx3Pixels rc={0:D}&amp;quot;, rc);&lt;br /&gt;
                for (int i = 0; i &amp;lt; Math.Min(10, pixelCount); i++)&lt;br /&gt;
                {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;        i:{0} pxIdx={1} toa={2} tot={3}&amp;quot;, i, pixelBuffer[i].index, pixelBuffer[i].toa, pixelBuffer[i].tot);&lt;br /&gt;
                }&lt;br /&gt;
                if (pixelCount&amp;gt;10) Console.WriteLine(&amp;quot;        ...&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        public static string GetErrorMessage(bool isErr)&lt;br /&gt;
        {&lt;br /&gt;
            if (isErr)&lt;br /&gt;
            {&lt;br /&gt;
                StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
                pxcGetLastError(errBuff, 256);&lt;br /&gt;
                return &amp;quot;err:&#039;&amp;quot; + errBuff.ToString() + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else return &amp;quot;OK&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) { // ===========================================================================&lt;br /&gt;
            int rc;&lt;br /&gt;
            StringBuilder errBuff = new StringBuilder(256);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcInitialize...&amp;quot;);&lt;br /&gt;
            //rc = pxcInitialize(0, 0); // before 1.8.5&lt;br /&gt;
            rc = pxcInitialize();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDevicesCount...&amp;quot;);&lt;br /&gt;
            int devCnt = pxcGetDevicesCount();&lt;br /&gt;
            Console.WriteLine($&amp;quot;rc={devCnt:D} {GetErrorMessage(devCnt &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
            StringBuilder nameBuffer = new StringBuilder(256);&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcGetDeviceName...&amp;quot;);&lt;br /&gt;
            for (uint n = 0; n &amp;lt; devCnt; n++)&lt;br /&gt;
            {&lt;br /&gt;
                rc = pxcGetDeviceName(n, nameBuffer, 256);&lt;br /&gt;
                Console.WriteLine(&amp;quot;    n:{0} rc={1:D} nam:{2}\n&amp;quot;, n, rc, nameBuffer.ToString());&lt;br /&gt;
            }&lt;br /&gt;
            if (devCnt &amp;gt; 0) {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Note: A data measured immediatelly afther init can contain chip starting artifacts&amp;quot;);&lt;br /&gt;
                Console.WriteLine(&amp;quot;      In real application add wait user response, feve seconds, dummy measurement or do sensor refresh&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
                Console.WriteLine(&amp;quot;pxcMeasureTpx3DataDrivenMode...&amp;quot;);&lt;br /&gt;
                rc = pxcMeasureTpx3DataDrivenMode(0, 10.0, &amp;quot;&amp;quot;, 0, Marshal.GetFunctionPointerForDelegate(new AcqEventFunc(AcqEventCallback)), IntPtr.Zero);&lt;br /&gt;
                Console.WriteLine($&amp;quot;pxcMeasureTpx3DataDrivenMode end: rc={rc:D} {GetErrorMessage(rc &amp;lt; 0)}&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                Console.WriteLine(&amp;quot;No devices detected\n&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            Console.WriteLine(&amp;quot;pxcExit...&amp;quot;);&lt;br /&gt;
            rc = pxcExit();&lt;br /&gt;
            Console.WriteLine(&amp;quot;rc={0:D}&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See: [[ C-sharp commandline examples]]&lt;br /&gt;
&lt;br /&gt;
=== C# Windows desktop example ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[C-sharp windows example]]&lt;br /&gt;
&lt;br /&gt;
== Python using Ctypes example ==&lt;br /&gt;
(Inspiration if you really want to experience such harakiri)&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width:100%;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&#039;&#039;&#039;Expand the example --&amp;gt;&#039;&#039;&#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
import os, sys, ctypes&lt;br /&gt;
from ctypes import byref, c_int, c_uint, c_char_p, c_char, POINTER, create_string_buffer&lt;br /&gt;
&lt;br /&gt;
# Use apiPath &amp;quot;.&amp;quot; for this .py in the API directory or some full path to API package in other location&lt;br /&gt;
#apiPath = &amp;quot;.&amp;quot;&lt;br /&gt;
apiPath = &amp;quot;C:/Advacam/API-nightly&amp;quot;&lt;br /&gt;
thisPath = os.path.dirname(os.path.abspath(__file__))&lt;br /&gt;
&lt;br /&gt;
def _load_pxcore(api_path: str) -&amp;gt; ctypes.CDLL:&lt;br /&gt;
    dll_path = os.path.join(api_path, &amp;quot;pxcore.dll&amp;quot;)&lt;br /&gt;
    if not os.path.isfile(dll_path):&lt;br /&gt;
        raise FileNotFoundError(f&amp;quot;pxcore.dll not found at: {dll_path}&amp;quot;)&lt;br /&gt;
    return ctypes.WinDLL(dll_path)&lt;br /&gt;
&lt;br /&gt;
def _bind_exports(px: ctypes.CDLL) -&amp;gt; None:&lt;br /&gt;
    px.pxcInitialize.argtypes = [c_char_p]&lt;br /&gt;
    px.pxcInitialize.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcExit.argtypes = []&lt;br /&gt;
    px.pxcExit.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDevicesCount.argtypes = []&lt;br /&gt;
    px.pxcGetDevicesCount.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.pxcGetDeviceName.argtypes = [c_uint, POINTER(c_char), c_uint]&lt;br /&gt;
    px.pxcGetDeviceName.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    px.OPM_TOATOT = 0&lt;br /&gt;
    px.OPM_EVENT_ITOT = 2&lt;br /&gt;
&lt;br /&gt;
    #int pxcSetTimepix3Mode(unsigned deviceIndex, int mode);&lt;br /&gt;
    px.pxcSetTimepix3Mode.argtypes = [c_uint, c_int]&lt;br /&gt;
    px.pxcSetTimepix3Mode.restype = c_int&lt;br /&gt;
&lt;br /&gt;
    #int pxcGetDeviceDimensions(unsigned deviceIndex, unsigned* width, unsigned* height);&lt;br /&gt;
    px.pxcGetDeviceDimensions.argtypes = [c_uint, POINTER(c_uint), POINTER(c_uint)]&lt;br /&gt;
    px.pxcGetDeviceDimensions.restype&lt;br /&gt;
&lt;br /&gt;
    #int pxcMeasureSingleFrameTpx3(unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgStg = PXC_TRG_NO);&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.argtypes = [c_uint, ctypes.c_double, POINTER(ctypes.c_double), POINTER(ctypes.c_ushort), POINTER(c_uint), c_uint]&lt;br /&gt;
    px.pxcMeasureSingleFrameTpx3.restype = c_int&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _showError(px: ctypes.CDLL) -&amp;gt; int:&lt;br /&gt;
    buf = create_string_buffer(4096)&lt;br /&gt;
    rc = px.pxcGetLastError(buf, ctypes.sizeof(buf))&lt;br /&gt;
    if rc != 0: print(&amp;quot;(pxcGetLastError failed&amp;quot;, rc, &amp;quot;)&amp;quot;)&lt;br /&gt;
    else: print(&amp;quot;Err:&amp;quot;, buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
    return rc&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(apiPath) # change dir to API root, otherwise some devices cannot be initialized&lt;br /&gt;
&lt;br /&gt;
px = _load_pxcore(apiPath)&lt;br /&gt;
_bind_exports(px)&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;pxcore init...&amp;quot;)&lt;br /&gt;
rc = px.pxcInitialize(b&amp;quot;pixet.ini&amp;quot;)&lt;br /&gt;
print(&amp;quot;pxcInitialize rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
if rc != 0:&lt;br /&gt;
    _showError(px)&lt;br /&gt;
    exit()&lt;br /&gt;
&lt;br /&gt;
if apiPath != &amp;quot;.&amp;quot;: os.chdir(thisPath) # change dir back or somewhere&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    devCnt = px.pxcGetDevicesCount()&lt;br /&gt;
    if devCnt &amp;lt; 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcGetDevicesCount failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Devices found:&amp;quot;, devCnt)&lt;br /&gt;
    if devCnt &amp;lt;= 0: raise RuntimeError(&amp;quot;No devices found&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    name_buf = create_string_buffer(512)&lt;br /&gt;
    for n in range(devCnt):&lt;br /&gt;
        rc = px.pxcGetDeviceName(n, name_buf, ctypes.sizeof(name_buf))&lt;br /&gt;
        if rc == 0:&lt;br /&gt;
            print(&amp;quot;  n:&amp;quot;, n, &amp;quot;name:&amp;quot;, name_buf.value.decode(&amp;quot;utf-8&amp;quot;, errors=&amp;quot;replace&amp;quot;))&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;  n: pxcGetDeviceName rc:&amp;quot;, rc)&lt;br /&gt;
            _showError(px)&lt;br /&gt;
&lt;br /&gt;
    pxIdx = 0&lt;br /&gt;
    print(&amp;quot;Selected device:&amp;quot;, pxIdx, &amp;quot;(if it isn&#039;t Tpx3, next code cannot work properly)&amp;quot;)&lt;br /&gt;
    devWidth = c_uint()&lt;br /&gt;
    devHeight = c_uint()&lt;br /&gt;
    devPixels = 65536 # default val. for singlechip&lt;br /&gt;
    rc = px.pxcGetDeviceDimensions(pxIdx, byref(devWidth), byref(devHeight))&lt;br /&gt;
    if rc == 0:&lt;br /&gt;
        devPixels = devWidth.value * devHeight.value&lt;br /&gt;
        print(&amp;quot;Dev dimensions:&amp;quot;, devWidth.value, &amp;quot;x&amp;quot;, devHeight.value, &amp;quot;pixels:&amp;quot;, devPixels)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;pxcGetDeviceDimensions rc:&amp;quot;, rc)&lt;br /&gt;
        _showError(px)&lt;br /&gt;
&lt;br /&gt;
    rc = px.pxcSetTimepix3Mode(pxIdx, px.OPM_EVENT_ITOT)&lt;br /&gt;
    print(&amp;quot;pxcSetTimepix3Mode rc:&amp;quot;, rc, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc!= 0: _showError(px)&lt;br /&gt;
&lt;br /&gt;
    frameToaITot = (ctypes.c_double * devPixels)()&lt;br /&gt;
    frameTotEvent = (ctypes.c_ushort * devPixels)()&lt;br /&gt;
    size = ctypes.c_ulong(devPixels)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3...&amp;quot;)&lt;br /&gt;
    rc = px.pxcMeasureSingleFrameTpx3(pxIdx, 1.0, frameToaITot, frameTotEvent, byref(size), 0)&lt;br /&gt;
    print(&amp;quot;pxcMeasureSingleFrameTpx3 rc:&amp;quot;, rc, &amp;quot;(0 is OK) size:&amp;quot;, size.value)&lt;br /&gt;
    if rc != 0:&lt;br /&gt;
        _showError(px)&lt;br /&gt;
        raise RuntimeError (&amp;quot;pxcMeasureSingleFrameTpx3 failed&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    ToaItMin = min(frameToaITot)&lt;br /&gt;
    ToaItMax = max(frameToaITot)&lt;br /&gt;
    TotEvMin = min(frameTotEvent)&lt;br /&gt;
    TotEvMax = max(frameTotEvent)&lt;br /&gt;
&lt;br /&gt;
    hits = 0&lt;br /&gt;
    for n in range(devPixels):&lt;br /&gt;
        if frameToaITot[n] != 0 | frameTotEvent[n] != 0: hits += 1&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;Frame stats: hits:&amp;quot;, hits, &amp;quot;ToaIt min/max:&amp;quot;, ToaItMin, ToaItMax, &amp;quot;TotEv min/max:&amp;quot;, TotEvMin, TotEvMax)&lt;br /&gt;
&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(&amp;quot;Exception:&amp;quot;, e)&lt;br /&gt;
&lt;br /&gt;
finally:&lt;br /&gt;
    print(&amp;quot;pxcore exit...&amp;quot;)&lt;br /&gt;
    rc2 = px.pxcExit()&lt;br /&gt;
    print(&amp;quot;pxcExit rc:&amp;quot;, rc2, &amp;quot;(0 is OK)&amp;quot;)&lt;br /&gt;
    if rc2 != 0: _showError(px)&lt;br /&gt;
    else:        print(&amp;quot;Done&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Commandline output:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pxcore init...&lt;br /&gt;
pxcInitialize rc: 0 (0 is OK)&lt;br /&gt;
Devices found: 6&lt;br /&gt;
  n: 0 name: MiniPIX I08-W0060&lt;br /&gt;
  n: 1 name: WidePIX D09-W0561-5&lt;br /&gt;
  n: 2 name: WidePIX F10-W0547-5&lt;br /&gt;
  n: 3 name: WidePIX F07-W0562-5&lt;br /&gt;
  n: 4 name: WidePIX D09-W0558-5&lt;br /&gt;
  n: 5 name: WidePIX G06-W0544-5&lt;br /&gt;
Selected device: 0 (if it isn&#039;t Tpx3, next code cannot work properly)&lt;br /&gt;
Dev dimensions: 256 x 256 pixels: 65536&lt;br /&gt;
pxcSetTimepix3Mode rc: 0 (0 is OK)&lt;br /&gt;
pxcMeasureSingleFrameTpx3...&lt;br /&gt;
pxcMeasureSingleFrameTpx3 rc: 0 (0 is OK) size: 65536&lt;br /&gt;
Frame stats: hits: 60 ToaIt min/max: 0.0 15523.0 TotEv min/max: 0 707&lt;br /&gt;
pxcore exit...&lt;br /&gt;
pxcExit rc: 0 (0 is OK)&lt;br /&gt;
Done&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API header definition =&lt;br /&gt;
All API functions are defined in the pxcapi.h file. Each definition starting with the &#039;&#039;&#039;PXCAPI&#039;&#039;&#039; keyword:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#ifndef WIN32 // Linux&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __attribute__ ((visibility(&amp;quot;default&amp;quot;)))&lt;br /&gt;
#else         // Windows&lt;br /&gt;
    #define PXCAPI extern &amp;quot;C&amp;quot; __declspec(dllexport)&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= API auxiliary functions =&lt;br /&gt;
This chapter describes auxiliary functions. There are need for normal using of the device, but it not measuring or processing data.&lt;br /&gt;
&lt;br /&gt;
== Start-up, end, errors ==&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInitialize &lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function initializes the Pixet software and all connected devices. This function has to be called first before any other function except pxcGetLastError. The init process of each device is:&lt;br /&gt;
# Initialize hardwrare and communication&lt;br /&gt;
# Try to load device XML config file from the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# If failed, try to load device XML config file from the &amp;quot;factory&amp;quot; dir&amp;lt;br&amp;gt;&lt;br /&gt;
: Warning: If the correct config is not loaded, the device will not work properly and may do strange things.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char *iniFile=&amp;quot;pixet.ini&amp;quot;&lt;br /&gt;
| iniFile – name/path to pxcore main ini file.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Change parameters since Pixet 1.8.5, previous pxcInitialize has (int argc = 0, char const* argv[] = NULL)&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcInitialize();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcExit&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function deinitializes Pixet software and all the connected devices. This function has to be called as last function before unloading the pxcore library. The exit process of each device is:&lt;br /&gt;
# Save actual device XML config file to the &amp;quot;configs&amp;quot; dir&lt;br /&gt;
# Deinitialization of the hardware and communication&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|The factory and the configs subdirectories]]&amp;lt;br&amp;gt;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcExit();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDirectories&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the configuration files directory and directory for log files. Has to be set before calling the pxcInitialize function. Use it to change its default locations defined by pixet.ini.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See&#039;&#039;&#039;&lt;br /&gt;
: [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|Files and directories of the Pixet and SDK: The factory and the configs subdirectories]]&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = const char* configsDir, const char* logsDir&lt;br /&gt;
| configsDir – Path to the directory for loading/saving config files&lt;br /&gt;
| logsDir – Path to the directory for saving log files&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRefreshDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function looks for newly connected devices and removed disconnected devices from the device list.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcRefreshDevices();&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcReconnectDevice&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = If the device was disconnected or experienced communication problems, this function will try to reconnect the device and reinitialize it. Like as do the pxcExit and pxcInitialize, but only for one device index. The process is:&lt;br /&gt;
# Saves the device config to the “configs” directory&lt;br /&gt;
# Disconnects the device&lt;br /&gt;
# Connects the device&lt;br /&gt;
# Loads the device config&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcReconnectDevice(0); // reconnect device with index 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetLastError&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns text of last error. This function can be called even before pxcInitialize()&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = char* errorMsgBuffer, unsigned size&lt;br /&gt;
| errorMsgBuffer - buffer where text will be saved&lt;br /&gt;
| size - size of supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char msg[200];&lt;br /&gt;
pxcGetLastError(msg, 200);&amp;lt;br&amp;gt; printf(&amp;quot;Error msg: %s\n&amp;quot;, msg);&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Example1 (console)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #define ERRMSG_BUFF_SIZE 512&lt;br /&gt;
 #define ENTER_ON true&lt;br /&gt;
 #define ENTER_OFF false&lt;br /&gt;
 // (the function used in most examples in this manual)&lt;br /&gt;
 void printErrors(const char* fName, int rc, bool enter) {&lt;br /&gt;
    char errorMsg[ERRMSG_BUFF_SIZE];&lt;br /&gt;
    pxcGetLastError(errorMsg, ERRMSG_BUFF_SIZE);&lt;br /&gt;
    if (errorMsg[0]&amp;gt;0) {&lt;br /&gt;
        printf(&amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
    } else {&lt;br /&gt;
        printf(&amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
    }&lt;br /&gt;
    if (enter) printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If mode set was suscessfull, result is:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode 0 err: ---&#039;&#039;&#039;&lt;br /&gt;
If not, you can see some as:&lt;br /&gt;
: &#039;&#039;&#039;pxcSetTimepix3Mode -2 err: Invalid device index&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example2 (Windows CLR)&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 const unsigned cErrBufSize = 512;&lt;br /&gt;
 // primary use to show function name, return code, last error message&lt;br /&gt;
 bool errorToList(const char* fName, int rc) {&lt;br /&gt;
     char errorMsg[cErrBufSize];&lt;br /&gt;
     char cMsg[cErrBufSize];&lt;br /&gt;
     String^ eMsg;&lt;br /&gt;
     pxcGetLastError(errorMsg, cErrBufSize);&lt;br /&gt;
     if (rc!=0) {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: %s&amp;quot;, fName, rc, errorMsg);&lt;br /&gt;
         eMsg = gcnew String(errorMsg);&lt;br /&gt;
     } else {&lt;br /&gt;
         sprintf(cMsg, &amp;quot;%s %d err: ---&amp;quot;, fName, rc);&lt;br /&gt;
     };&lt;br /&gt;
     String^ sMsg = gcnew String(cMsg);&lt;br /&gt;
     listMessages-&amp;gt;Items-&amp;gt;Add(sMsg);&lt;br /&gt;
     return (rc!=0);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now you can use it:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_EVENT_ITOT);&lt;br /&gt;
 if (errorToList(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc)) return rc;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetIPixet&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns a core pointer for processing libraries, Clustering or Spectral imaging for example.&lt;br /&gt;
| DefH = PXCAPI void*&lt;br /&gt;
| DefP = (void)&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = core pointer&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (direct) ==&lt;br /&gt;
Functions described in this chapter working directly, function name defines parameter name and type.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For named parameters settings see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: Setting operation mode ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 // Set the operating mode&lt;br /&gt;
 rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOATOT);&lt;br /&gt;
 printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example: List of devices with parameters ===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot; line&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;pxcapi.h&amp;quot;&lt;br /&gt;
 #define CHT_Si 0&lt;br /&gt;
 #define CHT_CdTe 1&lt;br /&gt;
 char chipType = CHT_Unknown;&lt;br /&gt;
 int main(int argc, char const* argv[]) { // #######################################&lt;br /&gt;
     int rc = pxcInitialize();&lt;br /&gt;
     if (rc) {&lt;br /&gt;
         printf(&amp;quot;Could not initialize Pixet:\n&amp;quot;);&lt;br /&gt;
         printErrors(&amp;quot;pxcInitialize&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
         return -1;&lt;br /&gt;
     }&lt;br /&gt;
     int connectedDevicesCount = pxcGetDevicesCount();&lt;br /&gt;
     printf(&amp;quot;Connected devices: %d\n&amp;quot;, connectedDevicesCount);&lt;br /&gt;
     if (connectedDevicesCount == 0) return pxcExit();&lt;br /&gt;
     for (unsigned devIdx = 0; (signed)devIdx &amp;lt; connectedDevicesCount; devIdx++) {&lt;br /&gt;
         char deviceName[256];&lt;br /&gt;
         memset(deviceName, 0, 256);&lt;br /&gt;
         pxcGetDeviceName(devIdx, deviceName, 256);&lt;br /&gt;
         char chipID[256];&lt;br /&gt;
         memset(chipID, 0, 256);&lt;br /&gt;
         pxcGetDeviceChipID(devIdx, 0, chipID, 256);&lt;br /&gt;
         printf(&amp;quot;Device %d: Name %s, (first ChipID: %s)\n&amp;quot;, devIdx, deviceName, chipID);&lt;br /&gt;
     }&lt;br /&gt;
     double bias;&lt;br /&gt;
     rc = pxcGetBias(devIdx, &amp;amp;bias);&lt;br /&gt;
     if (bias &amp;lt; 0.0) {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_CdTe;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: CdTe\n&amp;quot;);&lt;br /&gt;
     } else if (bias == 0.0) {&lt;br /&gt;
         printf(&amp;quot;Chip material not detected!\n&amp;quot;);&lt;br /&gt;
     } else {&lt;br /&gt;
         if (devIdx == 0) chipType = CHT_Si;&lt;br /&gt;
         printf(&amp;quot;Chip material detected: Si\n&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     printf(&amp;quot;=================================================================\n&amp;quot;);&lt;br /&gt;
     &lt;br /&gt;
     // here can be working code (calling some example function from this manual)&lt;br /&gt;
     &lt;br /&gt;
     return pxcExit();&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDevicesCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of connected and initialized devices.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of devices, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Connected devices count: %d\n&amp;quot;, pxcGetDevicesCount());&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcListNetworkDevices&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Searches for available network devices and store basic information about it to arrary. This is special function, independent of the Pixet Core. Can be used for listing devices without the PXcore initialized to prevent &amp;quot;steal&amp;quot; of other devices on the network. The output is usesfull to browse/testing network devices, it&#039;s IPs and availability on the network subnets. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = NetworkDevInfo* devInfos, unsigned* size&lt;br /&gt;
| devInfos - Pointer to array of NetworkDevInfo{char ip[15]; char name[20]; int serial;} structures&lt;br /&gt;
| size - [in] Pointer to size of the devInfo (number of elements) / [out] Value overwritten by the number of devices found&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Returns 0 if OK or PXCERR_BUFFER_SMALL if the number of devices exceeded the size of the array (the array is still filled and *size is set) &lt;br /&gt;
| Not = 1. Can be used independent of the Pixet core.&amp;lt;br&amp;gt;2. A related feature is planned, allowing you to select devices to be used by PXcore. Currently you can write to the zest.ini instead.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = NetworkDevInfo ndi[256];&lt;br /&gt;
unsigned ndiSize = 256;&lt;br /&gt;
int rc;&lt;br /&gt;
msgToList(&amp;quot;pxcListNetworkDevices...&amp;quot;);&lt;br /&gt;
//pxcListNetworkDevices(NetworkDevInfo* devInfos, unsigned* size);&lt;br /&gt;
rc = pxcListNetworkDevices(ndi, &amp;amp;ndiSize);&lt;br /&gt;
errorToList(&amp;quot;pxcListNetworkDevices&amp;quot;, rc);&lt;br /&gt;
if (rc != 0 &amp;amp;&amp;amp; rc != PXCERR_BUFFER_SMALL) return;&lt;br /&gt;
for (int n=0; n &amp;lt; ndiSize; n++) {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;  IP: {0}\t Name: {1}\t SN: {2}&amp;quot;, gcnew String(ndi[n].ip), gcnew String(ndi[n].name), ndi[n].serial));&lt;br /&gt;
}&lt;br /&gt;
if (ndiSize == 0) msgToList(&amp;quot;  (no devs found)&amp;quot;);&lt;br /&gt;
else if (rc == PXCERR_BUFFER_SMALL) msgToList(&amp;quot;  (and more devs than ndi array size)&amp;quot;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Network device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
struct NetworkDevInfo{&lt;br /&gt;
    char ip[15];&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceInfo&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets device info structure and returns devType. If *devInfo is NULL, only returns devType.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, CDevInfo *devInfo&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| devInfo – pointer to CDevInfo struct&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Device type number&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = // simple use:&lt;br /&gt;
if (pxcGetDeviceInfo(devIdx, NULL) != TPX3) errorMsg(&amp;quot;The device is not Timepix3&amp;quot;);&lt;br /&gt;
// Advanced use:&lt;br /&gt;
CDevInfo devInfo[20];&lt;br /&gt;
const char *dtStrings[] = {&amp;quot;Tpx&amp;quot;, &amp;quot;Mpx3&amp;quot;, &amp;quot;Tpx3&amp;quot;, &amp;quot;Tpx2&amp;quot;};&lt;br /&gt;
for (int n=0; n&amp;lt;pxcGetDevicesCount(); n++) {&lt;br /&gt;
    pxcGetDeviceInfo(n, devInfo[n]);&lt;br /&gt;
    printf(&amp;quot;DevIdx %d: Name: %s, SN: %d, DevType: %s&amp;quot;, n, devInfo[n].name, devInfo[n].serial, dtStrings[devInfo[n].type-1]);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&#039;&#039;&#039;Device info details:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
enum DevType{&lt;br /&gt;
    TPX = 1, MPX3, TPX3, TPX2,&lt;br /&gt;
};&lt;br /&gt;
struct CDevInfo{&lt;br /&gt;
    char name[20];&lt;br /&gt;
    int serial;&lt;br /&gt;
    DevType type;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceName&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the full name of the selected device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, char* nameBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| nameBuffer – buffer where the name of the device will be saved. Cannot be NULL&lt;br /&gt;
| size – size of the supplied name buffer &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char name[100];&lt;br /&gt;
pxcGetDeviceName(deviceIndex, name, 100);&lt;br /&gt;
printf(&amp;quot;Dev %d name: %s\n&amp;quot;, deviceIndex, name);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns number of chips in the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of chips if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has chip count: %d\n&amp;quot;, deviceIndex, pxcGetDeviceChipCount(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceChipID&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the ID of chip of the detector connected to the readout device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, char* chipIDBuffer, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip in the device, starting from zero&lt;br /&gt;
| chipIDBuffer – buffer where the chipID of the detector will be saved. Cannot be NULL&lt;br /&gt;
| size - size of the supplied chipID buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char id[50];&lt;br /&gt;
int rc = pxcGetDeviceChipID(deviceIndex, 0, id, 50);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Chip 0 of dev %d have ID: %s\n&amp;quot;, deviceIndex, id);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceChipID failed, code: %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceSerial&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns the devise serial number.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Serial number (&amp;gt;0) if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = printf(&amp;quot;Dev %d has serial number: %d\n&amp;quot;, deviceIndex, pxcGetDeviceSerial(deviceIndex));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceDimensions&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets pixel width and height of the device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned *w, unsigned *h&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| w – pointer to unsigned variable where the width of the device will be returned&lt;br /&gt;
| h – pointer to unsigned variable where the height of the device will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned w, h;&lt;br /&gt;
int rc = pxcGetDeviceDimensions(deviceIndex, &amp;amp;w, &amp;amp;h);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Width: %d, Height %d [px]\n&amp;quot;, w, h);&lt;br /&gt;
else printf(&amp;quot;pxcGetDeviceDimensions failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the bias voltage (high voltage) of the sensor chip.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* bias&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| bias – pointer to double variable where current bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double bias;&lt;br /&gt;
int rc = pxcGetBias(deviceIndex, &amp;amp;bias);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias: %f V\n&amp;quot;, bias);&lt;br /&gt;
else printf(&amp;quot;pxcGetBias failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBiasRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the range of the allowed minimal and maximal bias values.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* minBias, double* maxBias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| minBias – pointer to double variable where minimum allowed bias will be returned&lt;br /&gt;
| maxBias – pointer to double variable where maximum allowed bias will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double min, max;&lt;br /&gt;
int rc = pxcGetBiasRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Bias min: %f, max: %f V\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetBiasRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetBias&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the high voltage (bias) of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double bias&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| bias – high voltage in volts (limits and polarity depending on the device configuration, see: pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetBias(0, -350); // set bias -350 V to device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the threshold of the detector. Output value is normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double* threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for all except Medipix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – pointer to double variable where threshold will be saved. The value is several keVs with decimals or from 0 to a some power of two (depending of device DAC bits depth).&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double thl;&lt;br /&gt;
int rc = pxcGetThreshold(deviceIndex, &amp;amp;thl);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold: %f\n&amp;quot;, thl);&lt;br /&gt;
else printf(&amp;quot;pxcGetThreshold failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetThresholdRange&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the allowed range of values for threshold. Output values are normally in keV, but if the device not properly configurated, output is didital DAC value.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int thresholdIndex, double* minThreshold, double* maxThreshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex – for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| minThreshold – pointer to double variable where the minimal allowed threshold will be returned&lt;br /&gt;
| maxThreshold – pointer to double variable where the maximal allowed threshold will be returned&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  double min, max;&lt;br /&gt;
int rc = pxcGetThresholdRange(deviceIndex, &amp;amp;min, &amp;amp;max);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Threshold range - min: %f, max: %f\n&amp;quot;, min, max);&lt;br /&gt;
else printf(&amp;quot;pxcGetThresholdRange failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetThreshold&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the threshold of the detector in KeV.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned thresholdIndex, double threshold&lt;br /&gt;
| deviceIndex - index of the device, starting from zero&lt;br /&gt;
| thresholdIndex - for Timepix and Timepix3 always 0, for Medipix3 index of corresponding threshold starting from zero&lt;br /&gt;
| threshold – detector threshold in keV.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Too low thl value cause many noising pixels with all related problems.&lt;br /&gt;
| Exa = int rc = pxcSetThreshold(1, 0, 4.5); // set threshold with idx 0 on device with idx 1 to the 4.5 keV.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short* value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – pointer to output value be stored&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =  unsigned short val;&lt;br /&gt;
int rc = pxcGetDAC(deviceIndex, chipIndex, dacIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Input value of DAC with idx %d, on chip with idx %d, of device with idx %d is: %d\n&amp;quot;, deviceIndex, chipIndex, dacIndex, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetDAC failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDAC&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets a single DAC value of the detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned chipIndex, unsigned dacIndex, unsigned short value&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| chipIndex – index of the chip, starting from zero&lt;br /&gt;
| dacIndex – index of the DAC, starting from zero&lt;br /&gt;
| value – new DAC value&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetDAC(0, 1, 2, 123); // set DAC with idx 3 on chip with idx 2 on device with idx 1 to the 123.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of measurement clock for Timepix detector (in MHz).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – pointer to double variable where the clock will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = double val;&lt;br /&gt;
int rc = pxcGetTimepixClock(deviceIndex, &amp;amp;val);&lt;br /&gt;
if (rc==0) printf(&amp;quot;Timepix clock: %f MHz\n&amp;quot;, val);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixClock failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixClock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of measurement clock for Timepix detector (in MHz). Not all values are possible, the result will be the closest possible frequency.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired value of the measurement clock for Timepix detector&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN. Timepix3 has a fixed clock of 40 MHz. Timepix2 has other clocks managenment.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixClock(deviceIndex, 25.0);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current value of the Timepix mode (Counting, Energy,…)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Timepix mode if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
: Timepix mode can be:&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode if successful.&amp;lt;br&amp;gt;&lt;br /&gt;
: Otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcGetTimepixMode(deviceIndex);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Mode of dev. idx %d is: %d\n&amp;quot;, deviceIndex, rc);&lt;br /&gt;
else printf(&amp;quot;pxcGetTimepixMode failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix mode. One of the values:&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_MEDIPIX – counting mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TOT – energy mode&amp;lt;br&amp;gt;&lt;br /&gt;
: PXC_TPX_MODE_TIMEPIX – timepix mode&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| War =&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| Exa = int rc = pxcSetTimepixMode(0, PXC_TPX_MODE_MEDIPIX); // set dev 0 to mode counting alias MEDIPIX&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcSetTimepixCalibrationEnabled(0, true); // enable ToT calibration to keVs on device with idx 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepixCalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if disabled, greater than 0 enabled, negative value a PXCERR_XXX code&lt;br /&gt;
| Not = Only for the Timepix devices, not usable on Timepix3 and other TimepixN.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsTimepixCalibrationEnabled(0);&lt;br /&gt;
if (rc&amp;gt;=0) printf(&amp;quot;Calibration of dev0 is %s\n&amp;quot;, (rc==0) ? &amp;quot;disabled&amp;quot; : &amp;quot;enabled&amp;quot;);&lt;br /&gt;
else printf(&amp;quot;pxcIsTimepixCalibrationEnabled failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets the current clocks settings in the Timepix2 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double* totClock, double* toaClock, unsigned* divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| totClock – pointer to double variable where the ToT clock (in MHz) will be saved&lt;br /&gt;
| toaClock – pointer to double variable where the ToA clock (in MHz) will be saved&lt;br /&gt;
| divider – pointer to unsigned int variable where the divider value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed &lt;br /&gt;
clock of 40 MHz.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Clock&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets Timepix2 detector clocks settings.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double clock, unsigned divider&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| clock – desired new value of the ToT clock (in MHz) for the Timepix2 detector. The real frequency will be nearest possible division by 2’s power from the 50 MHz. Min is 1.5625 MHz.&lt;br /&gt;
| divider – value of the ToA divider index.&lt;br /&gt;
:Values means 0: disable, 1: no division, 2-30: div. by 2&amp;lt;sup&amp;gt;n-1&amp;lt;/sup&amp;gt;.&lt;br /&gt;
:The ToA clock will be divided from the ToT clock.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix. Timepix3 have a fixed clock of 40 MHz.&lt;br /&gt;
| War = The factory energy calibration is only for the 50 MHz ToT clock. Do not change ToT clock if using calibration or if you plan to post-calibrate the data.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – new value of the Timepix2 mode. One of the values:&lt;br /&gt;
:PXC_TPX2_OPM_TOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_TOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOT14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT10&lt;br /&gt;
:PXC_TPX2_OPM_CONT_CNT14&lt;br /&gt;
:PXC_TPX2_OPM_ITOT10_TOA18&lt;br /&gt;
:PXC_TPX2_OPM_ITOT14_TOA14&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT10_CNT4&lt;br /&gt;
:PXC_TPX2_OPM_CONT_ITOT14&lt;br /&gt;
:;Modes desctiption&lt;br /&gt;
::TOT – time over threshold in ToT ticks, or energy in keV if calibrated&lt;br /&gt;
::TOA – time of arrival in ToA ticks&lt;br /&gt;
::CNT – count of hits&lt;br /&gt;
::ITOT – integrated time over threshold in the pixel, or estimate energy if calibrated&lt;br /&gt;
::CONT – continual mode: One counter set counting while reading data from other counter set&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AdaptiveGainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool adaptiveGainOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| adaptiveGainOn – enable the adaptive gain feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2AnalogueMaskingMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function sets the value of Timepix2 mode&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool analogMaskOn&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| analogMaskOn – enable the analogue masking feature&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function enables or disables the calibration of Timepix ToT counts to energy in keV&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if the calibration is enabled or disable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix2CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function returns if the calibration of Timepix ToT counts to energy in keV is enabled&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Different acquisition or frame reading functions needed if calibration is on or off.&lt;br /&gt;
:Only for the Timepix2 devices, not usable on Timepix3 and other Timepix.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3Mode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Timepix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int mode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| mode – mode of the detector PXC_TPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables/disables the calibration of Timepix3 ToT counts to energy in keV. If enabled, output of a frame maesurements on the device will be calibrated.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if calibraiton is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Calibration working properly only if the device has loaded proper config.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets if the calibration of Timepix3 ToT counts to energy in keV is enabled. See [[#pxcSetTimepix3CalibrationEnabled|pxcSetTimepix3CalibrationEnabled]] for details.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = enabled &amp;gt; 0, disabled = 0, error &amp;lt; 0 – the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3OperationMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the operation mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int opMode&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| opMode – mode of the detector PXC_MPX3_OPM_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3GainMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the gain mode of Medipix3 detector&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int gain&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| gain – mode of the detector PXC_MPX3_GAIN_MOD_XXX values&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3AcqParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets acquisition parameters for Medipix3&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool colorMode, bool csm, int gain, bool equalize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| colorMode – if color mode is enabled&lt;br /&gt;
| csm – if charge sharing mode is enabled&lt;br /&gt;
| gain – gain settings (PXC_MPX3_GAIN_XXX values)&lt;br /&gt;
| equalize – if equalization bit in Medipix3 is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepixes or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetMedipix3MatrixParams&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets parameters of the Meidpix3 pixel matrix&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, int depth, int counter, int colBlock, int rowBlock&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| depth – depth of the counters PXC_MPX3_CNTD_XXX values&lt;br /&gt;
| counter – selected counter (PXC_MPX3_CNT_XXX values)&lt;br /&gt;
| colBlock – region of interest readout (PXC_MPX3_COLB_XXX values)&lt;br /&gt;
| rowBlock – region of interest readout (PXC_MPX3_ROWB_XXX values)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Pixel matrix and masks management ==&lt;br /&gt;
This section contains&lt;br /&gt;
* Management of pixel matrix configuration (low-level settings of each pixel)&lt;br /&gt;
* Management of masking bad/noisy pixels&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;New&#039;&#039;&#039;: Since version 1.8.5 are &#039;&#039;&#039;two masks&#039;&#039;&#039;:&lt;br /&gt;
# &#039;&#039;&#039;Device mask&#039;&#039;&#039; - Confirmed bad pixels to be normally masked&lt;br /&gt;
# &#039;&#039;&#039;User mask&#039;&#039;&#039; - Additional mask - User experiments playground. Can be simply cleared before lost of normal mask.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – pixel mask matrix. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the pixel matrix configuration. This is low level function for advanced users.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned char* maskMatrix, unsigned byteSize&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| maskMatrix – buffer where the mask matrix will be stored. 0 masked, 1 unmasked&lt;br /&gt;
| size – size of the mask matrix&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Metadata ==&lt;br /&gt;
Various devices, readout chips, detector chips and measurement methods have various metadata. To obtain informations about all relevant metadata for your purphose, set-up and run the testmeasurement with file-saving (using test code or Pixet program). Now you can read the accompanying DSC/INFO files, that contains all metadata for this combination of device/detector/measurement.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Frames and description files screenshot.png|frame|right|alt=Frames and description files screenshot|Frames and description files screenshot]]&lt;br /&gt;
;Example DSC records&lt;br /&gt;
:&amp;quot;Chips layout&amp;quot; (&amp;quot;Order of chips in matrix&amp;quot;):&lt;br /&gt;
:i32[5]&lt;br /&gt;
:4 3 0 1 2&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time&amp;quot; (&amp;quot;Acquisition start time&amp;quot;):&lt;br /&gt;
:double[1]&lt;br /&gt;
:1659611081.595321&lt;br /&gt;
:&lt;br /&gt;
:&amp;quot;Start time (string)&amp;quot; (&amp;quot;Acquisition start time (string)&amp;quot;):&lt;br /&gt;
:char[64]&lt;br /&gt;
:Thu Aug 4 13:04:41.595321 2022&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMetaDataValue&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function gets measured data meta data value. Output value is converted to char*.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned dataIndex, const char* metaDataName, char* valueBuffer, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| dataIndex - index of the measured data (frame), starting from zero&lt;br /&gt;
| metaDataName – name of the metadata to get, &amp;quot;Start time&amp;quot; for example.&lt;br /&gt;
| valueBuffer – buffer where the value of the meta data as string will be stored&lt;br /&gt;
| size – pointer to size of the supplied buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &#039;&#039;&#039;Metadata names&#039;&#039;&#039; obtaining:  Save some frame to file and see the avalilable metadata to a .dsc file saved with the image. Some image formats do not store metadata externally. Use e.g. txt, pmf, bmf.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = char mdb[200]; // metadata buffer&lt;br /&gt;
unsigned mdbs = 200; // metadata buffer size&lt;br /&gt;
char mdn[] = &amp;quot;Start time&amp;quot;; // metadata name&lt;br /&gt;
&lt;br /&gt;
int rc = pxcGetMetaDataValue(deviceIndex, frameLastIndex, mdn, mdb, &amp;amp;mdbs);&lt;br /&gt;
if (rc != 0) errorToList(&amp;quot;pxcGetMetaDataValue&amp;quot;, rc);&lt;br /&gt;
else msgToList(&amp;quot;Acquisition start time: &amp;quot; + gcnew String(mdb));&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Parameter Get/Set functions (using text paramName) ==&lt;br /&gt;
In this chapter are a functions that working with named parameters. Alias &#039;&#039;&#039;readout parameters&#039;&#039;&#039;: Because originally it was only about the parameters of the readout chips. Later, the setting of other device and software parameters was also added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;For dirrect setting functions see:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(direct)|Parameter Get/Set functions (direct)]]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Data Driven Block Size [B], default 66000&lt;br /&gt;
rc = pxcSetDeviceParameter(deviceIndex, &amp;quot;DDBlockSize&amp;quot;, 6000);&lt;br /&gt;
printf(&amp;quot;pxcSetDeviceParameter %d&amp;quot;, rc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the integer device parameter (e.g. settings of trigger)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, int parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to double variable where the parameter value will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterDouble&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device double parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, double parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns the value of device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – pointer to string buffer where the parameter value will be saved&lt;br /&gt;
| size – size of the passed buffer&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetDeviceParameterString&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets a value of the device string parameter&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* parameterName, const char* parameterValue&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| parameterName – name of the device parameter&lt;br /&gt;
| parameterValue – new value of the parameter&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Tpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_DUMMYACQ      &amp;quot;DummyAcqNegativePolarity&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CHIP     &amp;quot;TemperatureChip&amp;quot;&lt;br /&gt;
#define PAR_TEMP_CPU      &amp;quot;TemperatureCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHIP_CPU &amp;quot;TemperatureChipCpu&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_ACQSERIE &amp;quot;TemperatureReadBeforeAcqSerie&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_READ_EVERYACQ &amp;quot;TemperatureReadBeforeEachAcq&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_SW &amp;quot;CheckMaxTempInSW&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_CHECK_IN_CPU &amp;quot;CheckMaxChipTempInCPU&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TEMP_MAX_ALLOWED_TEMP &amp;quot;MaxAllowedChipTemp&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DAC_BANGAP      &amp;quot;DacBandGap&amp;quot;&lt;br /&gt;
#define PAR_DAC_TEMP        &amp;quot;DacTemp&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_VOLT &amp;quot;BiasSenseVoltage&amp;quot;&lt;br /&gt;
#define PAR_BIAS_SENSE_CURR &amp;quot;BiasSenseCurrent&amp;quot;&lt;br /&gt;
#define PAR_DD_BUFF_SIZE    &amp;quot;DDBuffSize&amp;quot;&lt;br /&gt;
#define PAR_DD_BLOCK_SIZE   &amp;quot;DDBlockSize&amp;quot;&lt;br /&gt;
#define META_SHUTTER_TIME   &amp;quot;Shutter open time&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_CHAN_MASK       &amp;quot;ChanMask&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_READOUT_CLOCK   &amp;quot;ReadoutClock&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_STG         &amp;quot;TrgStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_TIMESTAMP   &amp;quot;TrgTimestamp&amp;quot;&lt;br /&gt;
#define PAR_TRG_T0SYNC_RESET &amp;quot;TrgT0SyncReset&amp;quot;&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // no net/tpx3&lt;br /&gt;
#define PAR_TRG_OUTLEVEL     &amp;quot;TrgOutLevel&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_OUT_ENABLE   &amp;quot;TrgOutEnable&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_TRG_IS_MASTER    &amp;quot;IsMaster&amp;quot;&lt;br /&gt;
#define PAR_MOTOHOURS        &amp;quot;Motohours&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_MTX              &amp;quot;MTX&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_SEND_TOA_PIXELS  &amp;quot;SendDummyToaPixels&amp;quot; // mimipix/tpx3 only&lt;br /&gt;
#define PAR_DUMMYSPEED       &amp;quot;DDDummyDataSpeed&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_BLOCKCOUNT       &amp;quot;BlockCount&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_PROCESSDATA      &amp;quot;ProcessData&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_MULTI        &amp;quot;TrgMulti&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_ADVAPIX_ADC      &amp;quot;AdvaPixADC&amp;quot; // no mimipix/tpx3&lt;br /&gt;
#define PAR_TRG_READY        &amp;quot;TrgReady&amp;quot; // zem only&lt;br /&gt;
#define PAR_TRG_CMOS         &amp;quot;TrgCmos&amp;quot; // zem only&lt;br /&gt;
#define PAR_READOUT_CLOCK    &amp;quot;ReadoutClock&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tpx2 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_VOLT = &amp;quot;BiasSenseVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_SENSE_CURR = &amp;quot;BiasSenseCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_READOUT_CLOCK = &amp;quot;ReadoutClock&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TrgStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_IS_MASTER = &amp;quot;IsMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_MOTOHOURS = &amp;quot;Motohours&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_CPU = &amp;quot;TemperatureCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP_MAX_ALLOWED_TEMP = &amp;quot;MaxAllowedChipTemp&amp;quot;;&lt;br /&gt;
const static char* PAR_POWER_VOLT = &amp;quot;PowerSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CPU_SUPPLY_VOLT = &amp;quot;CPUSupplyVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_LDO_VOLT = &amp;quot;ChipLDOVoltage&amp;quot;;&lt;br /&gt;
const static char* PAR_INPUT_CURRENT = &amp;quot;DeviceInputCurrent&amp;quot;;&lt;br /&gt;
const static char* PAR_CHIP_CURRENT = &amp;quot;ChipCurrent&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx2 (Timepix) parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER        &amp;quot;HwLibVer&amp;quot; // all, include minipixes&lt;br /&gt;
#define PAR_DEBUGLOG      &amp;quot;DebugLog&amp;quot; // all, include minipixes&lt;br /&gt;
#define CFG_BINPIXCFG     &amp;quot;BinaryPixelCfg&amp;quot; // fei-minipix only&lt;br /&gt;
#define PAR_FIRMWARE      &amp;quot;Firmware&amp;quot; //widepix only&lt;br /&gt;
#define PAR_PS_COUNT      &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER    &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY      &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_TEMP          &amp;quot;Temperature&amp;quot; // no zem&lt;br /&gt;
#define PAR_BIASINCPU     &amp;quot;BiasInCpu&amp;quot; // widepix only&lt;br /&gt;
#define PAR_TRG_STG       &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER    &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL  &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_ALTERNATIVE &amp;quot;TriggerAlternative&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_TRG_TWODEVS   &amp;quot;TriggerTwoDevs&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_BURST_DISABLE &amp;quot;BurstDisable&amp;quot; // fitpix only&lt;br /&gt;
#define PAR_CPU_BIAS_SET  &amp;quot;*BiasSet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot; // widepix only&lt;br /&gt;
#define PAR_CPU_TEMP_DET  &amp;quot;TempDet&amp;quot; // widepix only&lt;br /&gt;
#define PAR_FASTACQ       &amp;quot;FastAcq&amp;quot; // zem only&lt;br /&gt;
#define PAR_BURST_FRAME_COUNT &amp;quot;BurstFrameCount&amp;quot; // zem only&lt;br /&gt;
#define PAR_PIXEL_BUFFSIZE &amp;quot;PixelBuffSize&amp;quot; // zem only&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mpx3 parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_TEMP              &amp;quot;Temperature&amp;quot;&lt;br /&gt;
#define PAR_TRG_STG           &amp;quot;TriggerStg&amp;quot;&lt;br /&gt;
#define PAR_TRG_WAITREADY     &amp;quot;TriggerWaitForReady&amp;quot;&lt;br /&gt;
#define PAR_TRG_MASTER        &amp;quot;TriggerMaster&amp;quot;&lt;br /&gt;
#define PAR_TRG_OUTLEVEL      &amp;quot;TriggerOutLevel&amp;quot;&lt;br /&gt;
#define PAR_TRG_SERIES        &amp;quot;TriggerTdiSeries&amp;quot;&lt;br /&gt;
#define PAR_TDI_ROWCOUNT      &amp;quot;TdiRowCount&amp;quot;&lt;br /&gt;
#define PAR_BIASINCPU         &amp;quot;BiasInCpu&amp;quot;&lt;br /&gt;
#define PAR_BIAS_DISCHARGE    &amp;quot;BiasDischarge&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_SET      &amp;quot;*BiasSet&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_VOLTSENSE &amp;quot;BiasVolt&amp;quot;&lt;br /&gt;
#define PAR_CPU_BIAS_CURRSENSE &amp;quot;BiasCurr&amp;quot;&lt;br /&gt;
#define PAR_CPU_TEMP_DET       &amp;quot;TempDet&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zest-wpxdev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
const static char* PAR_LIBVER = &amp;quot;HwLibVer&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE = &amp;quot;Firmware&amp;quot;;&lt;br /&gt;
const static char* PAR_FIRMWARE_CPU = &amp;quot;FirmwareCpu&amp;quot;;&lt;br /&gt;
const static char* PAR_DEBUGLOG = &amp;quot;DebugLog&amp;quot;;&lt;br /&gt;
const static char* PAR_TEMP = &amp;quot;Temperature&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_STG = &amp;quot;TriggerStg&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_WAITREADY= &amp;quot;TriggerWaitForReady&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_MASTER = &amp;quot;TriggerMaster&amp;quot;;&lt;br /&gt;
const static char* PAR_TRG_OUTLEVEL = &amp;quot;TriggerOutLevel&amp;quot;;&lt;br /&gt;
const static char* PAR_BIAS_DISCHARGE = &amp;quot;BiasDischarge&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Zem-wpx7dev parameter names list ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;Warning: Most parameters are for testing purposes only and you will not need them in normal use.&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#define PAR_LIBVER            &amp;quot;HwLibVer&amp;quot;&lt;br /&gt;
#define PAR_DEBUGLOG          &amp;quot;DebugLog&amp;quot;&lt;br /&gt;
#define PAR_PS_COUNT          &amp;quot;PreShutterClockCount&amp;quot;&lt;br /&gt;
#define PAR_PS_DIVIDER        &amp;quot;PreShutterClockDivider&amp;quot;&lt;br /&gt;
#define PAR_PS_DELAY          &amp;quot;PreShutterDelayClockCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_CNT     &amp;quot;EncoderPulseCount&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_DIR     &amp;quot;EncoderDirection&amp;quot;&lt;br /&gt;
#define PAR_ENC_PULSE_COUNTER &amp;quot;EncoderPulseCounter&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Other auxilliary functions ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadFactoryConfig&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device factory configuration. If the device has no intermal config memory, need the factory config file (with default config filename) in the factory directory. Use it if he measurement results or device behavior are strange, or allways by default.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcLoadFactoryConfig(deviceIndex);&lt;br /&gt;
if (rc!=0) errorToList(&amp;quot;pxcLoadFactoryConfig&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcLoadDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function loads device configuration from xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveDeviceConfiguration&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = This function saves device configuration to xml file&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| filePath – path to xml configuration file&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetupTestPulseMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables / Disables and setups parameters of the test pulse measurements&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool tpEnabled, double height, double period, unsigned count, unsigned spacing&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| tpEnabled – enables/disables test pulse measurement (in functions Measure..Frame(s))&lt;br /&gt;
| height – test pulse height (0 – 1.5 V)&lt;br /&gt;
| period – single test pulse period (1 – 256 us)&lt;br /&gt;
| count – number of test pulses (1 – 10000)&lt;br /&gt;
| spacing – spacing that is used during measurement (sub acquisition), good value is 4&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRegisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Registers an acquisition event callback that is called when corresponding event occurs&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqEventFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqEventFunc&lt;br /&gt;
| userData – user data that are passed to callback function. Use this as pointer or as 32/64bit integer, depending on system pointer size. The callback function will receive the userData value.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The AcqEventFunc definition:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef void (*AcqEventFunc)(intptr_t eventData, intptr_t userData);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcUnregisterAcqEvent&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Unregisters the acquisition event callback&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, const char* event, AcqFunc func, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| event – event name (PXC_ACQEVENT_XXX values)&lt;br /&gt;
| func – callback function of type AcqFunc&lt;br /&gt;
| userData – user data pointer that was used in pxcRegisterAcqEvent, for proper indetify the event&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSetSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sets the sensor refresh sequence text. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes. Suitable values depend on chip manufacturing technology details.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| refreshString – sensor refresh string&lt;br /&gt;
: refresh string defines steps with pairs of times &amp;lt;nowiki&amp;gt;[sec] and bias coefficients [1=100%]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: (physical bias values limited to min/max chip properties, see pxcGetBiasRange)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Special function for scientific or device developing using. Normally it not usesfull, normally use the default refresh parameters loaded from factory config.&lt;br /&gt;
| Exa = // (devIdx, &amp;quot;time1, coef1; time2, coef2; time3, coef3; ...&amp;quot;)&lt;br /&gt;
int rc = pxcSetSensorRefresh(0, &amp;quot;5, 2; 3, 1.5; 1, 1.2; 1, 1&amp;quot;);&lt;br /&gt;
printErrors(&amp;quot;pxcSetSensorRefresh&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs the sensor refresh. The sensor refresh is used to clean the sensor of free charges. Process containing sequence of bias changes and may take several seconds.&lt;br /&gt;
:Useful for devices with &#039;&#039;&#039;CdTe or CZT chip&#039;&#039;&#039;:&lt;br /&gt;
# Before the measurement, which should start right after the initialization.&lt;br /&gt;
# To improve the repeatability of measurements &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableSensorRefresh&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables automatic sensor refresh before each acquisition series and at periodic intervals.&lt;br /&gt;
: For more details see: pxcDoSensorRefresh&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled, double refreshTime&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if automatic sensor refresh is enabled&lt;br /&gt;
| refreshTime – sensor refresh is performed repeatedly after this time in seconds.&lt;br /&gt;
:If thime is 0, then the refresh is done only once before the measurement&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This is an &#039;&#039;&#039;analog part refresh&#039;&#039;&#039;, not a recovery from a digital failure.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcEnableTDI&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Enables TDI (Time Delayed Integration) measurement (if device supports it, single line Mpx3 for example). Usesful for scanning of linearly moving objects.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, bool enabled&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| enabled – if TDI is enabled&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = It is not advisable to combine TDI and pxcMeasureContinuous.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcIsReadyForSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Checks if the device is ready to accept software trigger.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 1 if ready, 0 if not ready, and negative if error, PXCERR_XXX code.&lt;br /&gt;
| Not = If you want to use this immediately after a function for starting acquisition, wait until it&#039;s ready by using pxcIsReadyForSoftwareTrigger.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcIsReadyForSoftwareTrigger(deviceIndex);&lt;br /&gt;
if (rc==1) msgToList(&amp;quot;Dev is ready to SW trigger&amp;quot;);&lt;br /&gt;
else if (rc==0) msgToList(&amp;quot;Dev is not ready to SW trigger&amp;quot;);&lt;br /&gt;
else errorToList(&amp;quot;pxcIsReadyForSoftwareTrigger&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcDoSoftwareTrigger&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Sends the software trigger: Start of acquisition with trgStg=PXC_TRG_SWSTART used.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = &lt;br /&gt;
| War =&lt;br /&gt;
| Exa = &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-based measuring functions =&lt;br /&gt;
[[File:Basic-measuring-example.png|frame|none|alt=Basic frame measuring example|Basic frame measuring example]]&lt;br /&gt;
The functions described in this chapter are used for frame-based measurements. Suitable for imaging, for example. After acquisition ends, you can read all the frame data (65536 pixels from every chip) to your buffer or save to the file. Acquisition can start by software (afther call a function, for example), or by HW trigger. Data types depends on chip technology and the operation mode.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Chip can generate one or two data blocks (event count and integrated times over threshold, for example) in one acquisition. Do not forget to set the operation mode. If mode not set, some devices measure something, but some other devices measure something else in this case.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:MiniPixTpx3-Frames – mode set, single frame, multiple frames with/without callback, continuous measuring&lt;br /&gt;
&lt;br /&gt;
== Frame-based basic measurement flow ==&lt;br /&gt;
&lt;br /&gt;
=== Prereguirements ===&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: (pxcSet...Mode &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] for example)&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&lt;br /&gt;
=== Single frame measurement ===&lt;br /&gt;
Run the measuring function pxcMeasureSingleFrame... &#039;&#039;&#039;by the chip type&#039;&#039;&#039; - [[Binary_core_API#pxcMeasureSingleFrameTpx3|&#039;&#039;&#039;pxcMeasureSingleFrameTpx3&#039;&#039;&#039;]] for example, for measure and get the data to Your buffer.&lt;br /&gt;
* Simple&lt;br /&gt;
* Slow if more frames needed&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The &#039;&#039;&#039;pxcMeasureSingleFrame&#039;&#039;&#039; is for &#039;&#039;&#039;obsolette&#039;&#039;&#039; first generation Timepix chips only.&lt;br /&gt;
* The &#039;&#039;&#039;Calibrated&#039;&#039;&#039; variants requires proper config including calibration table and threshold + other related settings in factory defaults (or values used in custom calibration).&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames without callback ===&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFrames|&#039;&#039;&#039;pxcMeasureMultipleFrames&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get count of measured frames: [[Binary_core_API#pxcGetMeasuredFrameCount|&#039;&#039;&#039;pxcGetMeasuredFrameCount&#039;&#039;&#039;]]&lt;br /&gt;
# Optional save some measured frame: [[Binary_core_API#pxcSaveMeasuredFrame|&#039;&#039;&#039;pxcSaveMeasuredFrame&#039;&#039;&#039;]]&lt;br /&gt;
# Optional get some measured frame to Your buffer using pxcGetMeasuredFrame...&#039;&#039;&#039;by the chip type&#039;&#039;&#039;. [[Binary_core_API#pxcGetMeasuredFrameTpx2|&#039;&#039;&#039;pxcGetMeasuredFrameTpx2&#039;&#039;&#039;]] for example.&lt;br /&gt;
&lt;br /&gt;
:* Simple&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is only available after the measurement is finished.&lt;br /&gt;
:* Can allocate large memory if too much frames measured.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks ===&lt;br /&gt;
# Optional register other callbacks using [[Binary_core_API#pxcRegisterAcqEvent|&#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|&#039;&#039;&#039;pxcMeasureMultipleFramesWithCallback&#039;&#039;&#039;]]&lt;br /&gt;
# While the measurement is running, callbacks are comingin. There, save the frames to a file or to buffer fot the online processing.&lt;br /&gt;
# Optional unregister all first registered callbacks using [[Binary_core_API#pxcUnegisterAcqEvent|&#039;&#039;&#039;pxcUnegisterAcqEvent&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
:* More complex&lt;br /&gt;
:* Faster than single frame&lt;br /&gt;
:* The data is available while measuring.&lt;br /&gt;
:* Can allocate large memory if too much frames measured because the data remains in memory just like without the callback.&lt;br /&gt;
&lt;br /&gt;
=== Multiple frames using callbacks and circular buffer ===&lt;br /&gt;
Same as [[Binary_core_API#pxcMeasureMultipleFramesWithCallback|pxcMeasureMultipleFramesWithCallback]] but the [[Binary_core_API#pxcMeasureContinuous|&#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039;]].&lt;br /&gt;
&lt;br /&gt;
* Non-blocking function&lt;br /&gt;
* Unlimited number of frames, using circular buffer&lt;br /&gt;
* Supports HW-based continuous measurement&lt;br /&gt;
&lt;br /&gt;
== Frame measuring and related functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned short* frameData, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single detector size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameMpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Medipix3 chips&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from first counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from second counter will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Medipix3 devices, not usable on Timepix or other Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix3 detector.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameToaITot, unsigned short* frameTotEvent, unsigned* size, unsigned trgstg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx3Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                               // return codes&lt;br /&gt;
   const unsigned cSize = 65536;         // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize];  // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];           // frame data - integrated time over threshold&lt;br /&gt;
   double time = 1.0;                    // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;                // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx3(di, time, frameToaITot, frameTotEvent, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame and returns its data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is disabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, unsigned* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is disabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleFrameTpx2Test(unsigned di) { // di – device index ========&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   unsigned frameData1[cSize];    // frame data - ToT data&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureSingleCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of single frame, calibrate ToT to energy and returns data. This is only for Timepix2 detector and &#039;&#039;&#039;only if calibration is enabled&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double frameTime, double* frameData1, unsigned* frameData2, unsigned* size, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single detector chip, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
: Only if Timepix2 calibration is enabled.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureSingleCalibratedFrameTpx2Test(unsigned di) { // di – device index =====&lt;br /&gt;
   int rc;                        // return codes&lt;br /&gt;
   const unsigned cSize = 65536;  // chip pixels count&lt;br /&gt;
   double frameData1[cSize];      // frame data - ToT data = calibrated to energy&lt;br /&gt;
   unsigned frameData2[cSize];    // frame data - ToA data&lt;br /&gt;
   double time = 1.0;             // frame acquisition time&lt;br /&gt;
   unsigned size = cSize;         // buffer size and measured data size&lt;br /&gt;
   int mode = PXC_TPX2_OPM_TOT10_TOA18;&lt;br /&gt;
   rc = pxcSetTimepix2Mode(di, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix2Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   rc = pxcMeasureSingleCalibratedFrameTpx2(di, time, frameData1, frameData2, &amp;amp;size, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureSingleCalibratedFrameTpx2&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   showFrameDual(frameData1, frameData2, mode);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFrames&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount,  double frameTime, unsigned trgStg&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesTpx3Test() { // =========================&lt;br /&gt;
   int rc;                              // return codes&lt;br /&gt;
   const unsigned cSize = 65536;        // chip pixels count&lt;br /&gt;
   unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
   double frameToaITot[cSize];          // frame data - integrated time over threshold&lt;br /&gt;
   double frameTime = 1.0;              // frame acquisition time&lt;br /&gt;
   unsigned frameCount = 5;             // frame count&lt;br /&gt;
   unsigned size = cSize;               // buffer size and measured data size&lt;br /&gt;
&lt;br /&gt;
   int mode = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
   rc = pxcSetTimepix3Mode(0, mode);&lt;br /&gt;
   printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
   printf(&amp;quot;measuring %d frames...\n&amp;quot;, frameCount);&lt;br /&gt;
&lt;br /&gt;
   pxcMeasureMultipleFrames(0, frameCount, frameTime, PXC_TRG_NO);&lt;br /&gt;
   printErrors(&amp;quot;pxcMeasureMultipleFrames&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
   for (unsigned n=0; n&amp;lt;frameCount; n++) {&lt;br /&gt;
      rc = pxcGetMeasuredFrameTpx3(0, n, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
      printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
      size = cSize;&lt;br /&gt;
      showFrameDual(frameTotEvent, frameToaITot, mode);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement of several frames to memory. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameCount, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameCount – numeber of frames to measure&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void pxcMeasureMultipleFramesWithCallbackTestTpx3(unsigned deviceIndex) { // ==============&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 1;&lt;br /&gt;
	unsigned frameCount = 5;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcMeasureMultipleFramesWithCallback&lt;br /&gt;
	(deviceIndex, frameCount, frameTime, PXC_TRG_NO, mmfCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureMultipleFramesWithCallback&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// Measure function ends, after all callbacks are serviced&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void mmfCallback(intptr_t acqCount, intptr_t userData) { // =================================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	const unsigned cSize = 65536; // chip pixels count&lt;br /&gt;
	unsigned short frameTotEvent[cSize]; // frame data - event count&lt;br /&gt;
	double frameToaITot[cSize]; // frame data - integrated time over threshold&lt;br /&gt;
	unsigned size = cSize; // buffer size and measured data size&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData); // data transferred from start function&lt;br /&gt;
	printf(&amp;quot;mmfCallback acqCount=%d, di=%d\n&amp;quot;, (unsigned)acqCount, usrData.di);&lt;br /&gt;
	rc = pxcGetMeasuredFrameTpx3&lt;br /&gt;
	(usrData.di, (unsigned)acqCount - 1, frameToaITot, frameTotEvent, &amp;amp;size);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredFrameTpx3&amp;quot;, rc, ENTER_OFF); printf(&amp;quot;, size=%d\n&amp;quot;, size);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		printf(&amp;quot;Measured frame index %lu, &amp;quot;, (unsigned)acqCount - 1);&lt;br /&gt;
		printf(&amp;quot;count %d\n&amp;quot;, pxcGetMeasuredFrameCount(usrData.di));&lt;br /&gt;
		showFrameDual(frameTotEvent, frameToaITot, usrData.opm);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
//The acqCount contains count of measured frames that are currently waiting in memory.&lt;br /&gt;
// You can use acqCount-1 as frame index to read.&lt;br /&gt;
// The userData is 64b number used to transfer some data from starting function to callback function.&lt;br /&gt;
// You can use it as data pointer like in this example, or simply as number with some overtyping.&lt;br /&gt;
typedef struct { // structure for userData, that is using in mmfCallback&lt;br /&gt;
	unsigned di; // device index&lt;br /&gt;
	int opm; // operation mode&lt;br /&gt;
} tMmfClbData;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureContinuous&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs an “endless” measurement of several frames to memory. The measurement is run until it’s aborted by pxcAbortMeasurement function. When each frame is measured, the supplied callback function is called and the userData parameter is passed as argument.&amp;lt;br&amp;gt;&lt;br /&gt;
: If the readot chip supposrt it, this function starts the HW continous mode (MPX3, TPX2). This means that the counters are alternating and at the same time measurement is being made with one and measurement data is being sent from the other. Therefore, up to a certain FPS, measurement is taking place 100% of the time. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameBufferSize, double frameTime, unsigned trgStg, FrameMeasuredCallback callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameBufferSize – number of frames in circular buffer&lt;br /&gt;
| frameTime – time of the measurment in seconds&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO.&lt;br /&gt;
| callback – pointer to function of FrameMeasuredCallback type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* This function, differently to other multi-frame measurements, not waiting for process end. It simply start measurement and program continue next.&lt;br /&gt;
* You can set-up the callback by 2 ways:&lt;br /&gt;
# Simply use pointer to callback function in the &#039;&#039;&#039;pxcMeasureContinuous&#039;&#039;&#039; function. After do it, the commandline program must not leave the function in which pxcMeasureContinuous was used until the measurement is canceled.&lt;br /&gt;
# First use the &#039;&#039;&#039;pxcRegisterAcqEvent&#039;&#039;&#039; to set-up the callback, second use pxcMeasureContinuous without callback pointer or with NULL. Now it is possible to leave the superior function and measuring continue working independent. Afther cancel of the measurement, may be needed use the &#039;&#039;&#039;pxcUnregisterAcqEvent&#039;&#039;&#039; before other use of the Acq event.&lt;br /&gt;
| War =&#039;&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* Aborting measuremet from its callback (like as in commandline example bellow) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
* This function may cause problems if combined with TDI. Recommend use the pxcMeasureMultipleFramesWithCallback.&lt;br /&gt;
| Exa =void pxcMeasureContinuousTestTpx3(unsigned deviceIndex) { // ==============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double frameTime = 2;&lt;br /&gt;
	unsigned buffrerFrames = 3;&lt;br /&gt;
	tMmfClbData usrData;&lt;br /&gt;
	usrData.di = deviceIndex;&lt;br /&gt;
&lt;br /&gt;
	usrData.cnt = 0; // num of frames to stop in callback (0 endless)&lt;br /&gt;
	usrData.opm = PXC_TPX3_OPM_EVENT_ITOT;&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, usrData.opm);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// method 1 (single step):&lt;br /&gt;
	//rc = pxcMeasureContinuous	(deviceIndex, buffrerFrames, frameTime, PXC_TRG_NO, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	//printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	// method 2 (2 steps):&lt;br /&gt;
	// register event&lt;br /&gt;
	pxcRegisterAcqEvent(0, PXC_ACQEVENT_ACQ_FINISHED, mcCallback, (intptr_t)&amp;amp;usrData);&lt;br /&gt;
	printErrors(&amp;quot;pxcRegisterAcqEvent&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	// start continuous measuring (method 2, step 2)&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, buffrerFrames, frameTime);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureContinuous&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	printf(&amp;quot;waiting for callbacks...\n&amp;quot;);&lt;br /&gt;
	getchar(); // waiting so that callbacks can come&lt;br /&gt;
	printf(&amp;quot;pxcMeasureContinuousTest: user end\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
/*The callback function is some as used in pxcMeasureMultipleFramesWithCallback example, but usrData structure contains&lt;br /&gt;
extra member, the cnt.This can be used to stop, whitch is additional in the callback: */&lt;br /&gt;
&lt;br /&gt;
static unsigned cnt = 0;&lt;br /&gt;
cnt++;&lt;br /&gt;
if (usrData.cnt &amp;gt; 0 &amp;amp;&amp;amp; cnt &amp;gt;= usrData.cnt) {&lt;br /&gt;
	// stop continuous measuring on user defined number of frames&lt;br /&gt;
	printf(&amp;quot;pxcAbortMeasurement...&amp;quot;);&lt;br /&gt;
	rc = pxcAbortMeasurement(usrData.di);&lt;br /&gt;
	printErrors(&amp;quot;pxcAbortMeasurement&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	printf(&amp;quot;Press enter to exit the program.\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAbortMeasurement&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Stopts the currently running measurement on the indexed device.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War = Aborting measuremet from its callback (like as in commandline example in pxcMeasureContinuous) can cause lags for tens of seconds. If the pxcAbortMeasurement called by other way (Button event in GUI for example), abort is fast.&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of measured frames in memory. Usesful with pxcMeasureMultipleFrames.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcSaveMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Saves the measured frame to a file on the harddrive. This can be used instead of the pxcGetMeasuredFrame.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, const char* filePath&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| filePath – path to the file where frame will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =void someCallback(intptr_t acqCount, intptr_t userData) { // ======================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	tMmfClbData usrData = *((tMmfClbData*)userData);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.txt&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	rc = pxcSaveMeasuredFrame(usrData.di, (unsigned)acqCount - 1, &amp;quot;testFile.png&amp;quot;);&lt;br /&gt;
	printErrors(&amp;quot;pxcSaveMeasuredFrame-txt&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
	/* List of file extensions (format automatically detected by extension in filename):&lt;br /&gt;
	#define PX_EXT_ASCII_FRAME &amp;quot;txt&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_FRAME &amp;quot;pbf&amp;quot;&lt;br /&gt;
	#define PX_EXT_MULTI_FRAME &amp;quot;pmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_BINARY_MULTI_FRAME &amp;quot;bmf&amp;quot;&lt;br /&gt;
	#define PX_EXT_COMP_TPXSTREAM &amp;quot;pcts&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS &amp;quot;t3p&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_PIXELS_ASCII &amp;quot;t3pa&amp;quot;&lt;br /&gt;
	#define PX_EXT_TPX3_RAW_DATA &amp;quot;t3r&amp;quot;&lt;br /&gt;
	#define PX_EXT_FRAME_DESC &amp;quot;dsc&amp;quot;&lt;br /&gt;
	#define PX_EXT_INDEX &amp;quot;idx&amp;quot;&lt;br /&gt;
	#define PX_EXT_CLUSTER_LOG &amp;quot;clog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXEL_LOG &amp;quot;plog&amp;quot;&lt;br /&gt;
	#define PX_EXT_PNG &amp;quot;png&amp;quot;&lt;br /&gt;
	#define PX_EXT_PIXET_RAW_DATA &amp;quot;prd&amp;quot;&lt;br /&gt;
    (t3.. formats not frames - cannot be used with pxcSaveMeasuredFrame) */&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrame&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, unsigned short* frameData, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData – pointer to buffer where data will be saved. For single chip detector size is 65536.&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable.&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =This function have only one framebuffer. This is fully sufficient for single-output devices and modes. In combined modes (ToA+ToT, Event+IToT, dual threshold) only first data are available (ToA, Event, Threshold0). To take both outputs from the combined modes, it is necessary to use specialized functions for the given type of detector.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, unsigned* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration disabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredCalibratedFrameTpx2&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame with calibration from memory.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned frameIndex, double* frameData1, unsigned* frameData2, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameData1 – pointer to buffer where calibrated ToT-&amp;gt;Energy data from the first counter (based on set operationmode) will be saved. For single detector chip size is 65536&lt;br /&gt;
| frameData2 – pointer to buffer where data from the second counter (based on set operation mode) will be saved. For single chip detector size is 65536&lt;br /&gt;
| size - pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix2 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
:For Timepix2 chip only and only if &#039;&#039;&#039;calibration enabled&#039;&#039;&#039;.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredFrameTpx3&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets data of specified measured frame from memory. For Timepix3 chip only.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned fameIndex, double* frameToaITot, unsigned short* frameToTEvent, unsigned* size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| frameIndex – index of the frame, starting from zero&lt;br /&gt;
| frameToaITot – pointer to buffer where data from ToA or iToT counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| frameTotEvent – pointer to buffer where data from ToT or Event counter (based on set operation mode) will be saved. For single chip detector, size is 65536&lt;br /&gt;
| size – pointer to varible with the size of the buffer. The actual size will be output to this variable&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Only for the Timepix3 devices, not usable on other Timepixes or Medipixes.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API data-driven measuring functions =&lt;br /&gt;
[[File:Cluster-example.png|right|300px|alt=Data-driven: Cluster example|Data-driven: Cluster example]]&lt;br /&gt;
The functions described in this chapter can be used if frame-based measurement is not good choice, in particle collision research, for example.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Data-driven &amp;quot;frameless&amp;quot; in comparsion with frames:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
:;Advantages&lt;br /&gt;
::It is possible to continual measure for any length of time and repeated pixel hits are not lost.&lt;br /&gt;
:;Disadvantages&lt;br /&gt;
::Each pixel is transmitted as a separate packet, including its position. Therefore, this mode is significantly more demanding on the transmission speed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Afther measurement start, data from every event is stored in the buffer. Pixels has structures (defined in the pxcapi.h):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
typedef struct _Tpx3Pixel {&lt;br /&gt;
	double       toa;   // time of arrival [1 ns]&lt;br /&gt;
	float        tot;   // time over threshold [25 ns] or energy [keV] if calibrated&lt;br /&gt;
	unsigned int index; // pixel position index on device frame&lt;br /&gt;
} Tpx3Pixel;&lt;br /&gt;
&lt;br /&gt;
#pragma pack(push, 1)&lt;br /&gt;
typedef struct _RawTpx3Pixel {&lt;br /&gt;
    u32  index:      24; // pixel index on device frame or data lost start/end tags if overflow==1&lt;br /&gt;
    u64  toa:        64; // time of arrival [25 ns] lower 14b from chip and extension from FPGA+computer *&lt;br /&gt;
    byte overflow:   1;  // overflow sign&lt;br /&gt;
    byte ftoa:       5;  // fast ToA [1/0.64 ns] expanded from 4 to 5 bits as part of phase correction&lt;br /&gt;
    u16  tot:        10; // time over threshold [25 ns]&lt;br /&gt;
} RawTpx3Pixel;&lt;br /&gt;
#pragma pack(pop)        // * or data lost start/end time if overflow==1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the RawTpx3Pixel only if it is really necessary.&lt;br /&gt;
See warning: [[The_RawTpx3Pixel_structure_in_memory|&#039;&#039;&#039;Warning for the RawTpx3Pixel structure in memory&#039;&#039;&#039;]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The Pixet core has a circular buffer in memory. For &#039;&#039;&#039;MiniPIX&#039;&#039;&#039;: The default size is 100 MB. There are blocks in the buffer. The default block size is 66000 bytes. Incoming data is stored in a block. The “new data” event (that can start the callback or save the blockt to file) occurs if:&lt;br /&gt;
* The data size reaches the block size&lt;br /&gt;
* Some data is in block over the timeout (500 ms)&lt;br /&gt;
* The measurement ends&lt;br /&gt;
If you need to process data more often, you can set smaller block size. But if blocks are too small, data transfer speed can fall and some data can be lost. This can occurs if block size is less than approximately 5000 bytes (minipix, depends on computer speed and other circumstances).&lt;br /&gt;
&lt;br /&gt;
; Data-driven buffers settings&lt;br /&gt;
: Buffer parameters: DDBuffSize, DDBlockSize&lt;br /&gt;
: See [[Binary_core_API#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
; AdvaPIX note&lt;br /&gt;
: Has DDBuffSize, DDBlockSize and DDBlockSizeDivider. &lt;br /&gt;
: Unlike MiniPIX, BlockSize is in megabytes, as is BufferSize. Smaller Block can be created using Divider.&lt;br /&gt;
&lt;br /&gt;
;Example projects&lt;br /&gt;
:&#039;&#039;&#039;MiniPixTpx3-DataDriven&#039;&#039;&#039;, commandline example – Set the parameters, use the callback and display the data, some auxiliary things and data convert. Save data to files. Without threads.&lt;br /&gt;
:&#039;&#039;&#039;AdvacamAPIexamples/Tpx3&#039;&#039;&#039;, Windows GUI CLR app – All common functions including data-driven measurements. Using threads.&lt;br /&gt;
&lt;br /&gt;
; Notes&lt;br /&gt;
: Data-driven measurements are compatible with the &#039;&#039;&#039;TOATOT operation mode only&#039;&#039;&#039;.&lt;br /&gt;
: Functions in this chapter is &#039;&#039;&#039;only for the Timepix3 devices&#039;&#039;&#039;, not usable on other Timepixes or Medipixes.&lt;br /&gt;
&lt;br /&gt;
== Data-driven special settings ==&lt;br /&gt;
The Pixet core has a circular buffer in memory to receiving new pixels.&lt;br /&gt;
* Size of buffer is named &#039;&#039;&#039;buffer size&#039;&#039;&#039;.&lt;br /&gt;
* Buffer is divided to blocks with &#039;&#039;&#039;block size&#039;&#039;&#039;.&lt;br /&gt;
Received data is continuously stored to the buffer.&lt;br /&gt;
* Every reaching next block, the callback New data occurs.&lt;br /&gt;
* At a low event rate, the callback is also called regularly, e.g. 500 ms on Minipix.&lt;br /&gt;
* When the buffer runs out, the measurement ends with an error.&lt;br /&gt;
* If file saving is used, data is not accumulated in the buffer, callbacks do not occur, the buffer never runs out and measurement may by very long.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ DD settings in named (readout) parameters&lt;br /&gt;
|-&lt;br /&gt;
! Parameter name / description !! MiniPIX Tpx3 !! AdvaPIX Tpx3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBuffSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of whole buffer || [MB]&amp;lt;br&amp;gt;default 100 || [MB]&amp;lt;br&amp;gt;default 2000&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSize&#039;&#039;&#039;&amp;lt;br&amp;gt;Size of each block || [B]&amp;lt;br&amp;gt;default 66000 || [MB]&amp;lt;br&amp;gt;default 5&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDBlockSizeDivider&#039;&#039;&#039;&amp;lt;br&amp;gt;Unit divider for smaller blocks on AdvaPIX || (has no) || [/MB]&amp;lt;br&amp;gt;default 1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;DDDummyDataSpeed&#039;&#039;&#039;&amp;lt;br&amp;gt;Virtual data speed of dummy device || (has no) || 24831&lt;br /&gt;
|}&lt;br /&gt;
Default values are optimized for maximum performance on developper&#039;s computer. Normally, it is enough to leave these values, but it is possible that by changing them you will speed up the measurement a little or reduce the CPU load on Your computer.&lt;br /&gt;
&lt;br /&gt;
See: [[Binary_core_API#pxcSetDeviceParameter|&#039;&#039;&#039;pxcSetDeviceParameter&#039;&#039;&#039;]], [[Binary_core_API#pxcGetDeviceParameter|&#039;&#039;&#039;pxcGetDeviceParameter&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
== Data-driven basic measurement flow ==&lt;br /&gt;
&#039;&#039;&#039;Required first&#039;&#039;&#039; - Use one of options:&lt;br /&gt;
* Ensure that pxcInitialize automatically loads the correct device configuration that you received from us or saved after changes. See [[Files_and_directories_of_the_Pixet_and_SDK#The_factory_and_the_configs_subdirectories|&#039;&#039;&#039;The factory and the configs subdirectories&#039;&#039;&#039;]]&lt;br /&gt;
* Or load the factory config using [[Binary_core_API#pxcLoadFactoryConfig|&#039;&#039;&#039;pxcLoadFactoryConfig&#039;&#039;&#039;]]&lt;br /&gt;
* Or load Your somewhere saved config using [[Binary_core_API#pxcLoadDeviceConfiguration|&#039;&#039;&#039;pxcLoadDeviceConfiguration&#039;&#039;&#039;]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Second&#039;&#039;&#039; or before measurement(s):&lt;br /&gt;
* Now change some settings as needed, Operation mode for example: ([[Binary_core_API#pxcSetTimepix3Mode|&#039;&#039;&#039;pxcSetTimepix3Mode&#039;&#039;&#039;]] Only PXC_TPX3_OPM_TOATOT supported for data-driven.&lt;br /&gt;
* Change advanced setting like as bias voltage or threshold. Do this only if you know what you need it for and be aware of possible side effects. In data-driven measurement be careful if setting lower than default thresholds, it can cause noising pixels.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If running in a &#039;&#039;&#039;commandline without wait for user&#039;&#039;&#039; response - Wait for the sensor chip to stabilize. It prevents unwanted artifacts in the first measurement.&lt;br /&gt;
* Wait feve seconds&lt;br /&gt;
* Or do sensor refresh&lt;br /&gt;
* Or do dummy acquisition&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;The measurement flow:&#039;&#039;&#039;&lt;br /&gt;
# Run the measuring function [[Binary_core_API#pxcMeasureTpx3DataDrivenMode|&#039;&#039;&#039;pxcMeasureTpx3DataDrivenMode&#039;&#039;&#039;]]&lt;br /&gt;
# Get count of measured pixels: [[Binary_core_API#pxcGetMeasuredTpx3PixelsCount|&#039;&#039;&#039;pxcGetMeasuredTpx3PixelsCount&#039;&#039;&#039;]]&lt;br /&gt;
# Get measured data by [[Binary_core_API#pxcGetMeasuredTpx3Pixels|&#039;&#039;&#039;pxcGetMeasuredTpx3Pixels&#039;&#039;&#039;]] to Your buffer.&lt;br /&gt;
# Optional [[Binary_core_API#pxcCalibrateTpx3PixelsAndFilter|&#039;&#039;&#039;pxcCalibrateTpx3PixelsAndFilter&#039;&#039;&#039;]] (working properly only if proper configuration with calibration loaded and data measured with default threshold and other related settings)&lt;br /&gt;
&lt;br /&gt;
Note: A &amp;quot;get&amp;quot; steps can be after measurement end (Short measurements only), or in a callback ACQ_NEW_DATA (recommended).&lt;br /&gt;
&lt;br /&gt;
== DD functions list ==&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcMeasureTpx3DataDrivenMode&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Performs a measurement with Timepix3 detector in Data Driven Mode (event by event mode, when stream of pixels is sent). &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, double measTime, const char* filename, unsigned trgStg, AcqEventFunc callback, intptr_t userData&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| measTime – the total time of the measurement in seconds. Use 0 for infinite.&lt;br /&gt;
| filename – output file name and path (extensions must end *.t3pa, *.trp, *.t3r)&lt;br /&gt;
| trgStg – settings of external trigger - one of the PXC_TRG_XXX values. Default PXC_TRG_NO&lt;br /&gt;
| callback – pointer to function of acqEventFunc type&lt;br /&gt;
| userData – pointer to some user object/memory that is passed in callback function&lt;br /&gt;
: See [[Binary_core_API#pxcRegisterAcqEvent|pxcRegisterAcqEvent]] for userData details&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use with callbacks can be combined with a file.&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = int rc = pxcMeasureTpx3DataDrivenMode(0, 15, &amp;quot;testfile.t3pa&amp;quot;);&lt;br /&gt;
// Measure for 15 seconds on device 0 with saving to the &amp;quot;testfile.t3pa&amp;quot; file&lt;br /&gt;
}}&lt;br /&gt;
;Example for online processing&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
void timepix3DataDrivenGetPixelsTest(unsigned deviceIndex) { // ============================&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
	double measTime = 30;&lt;br /&gt;
	int devIdx = deviceIndex; // transmitted over pointer for use in the callback function&lt;br /&gt;
&lt;br /&gt;
	// working with TOA, TOATOT, TOT_NOTOA, not working with EVENT_ITOT&lt;br /&gt;
	rc = pxcSetTimepix3Mode(deviceIndex, PXC_TPX3_OPM_TOA);&lt;br /&gt;
	printErrors(&amp;quot;pxcSetTimepix3Mode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BLOCK_SIZE, 6000); // block [B]&lt;br /&gt;
	printErrors(&amp;quot;pxcSetDeviceParameter&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	rc = pxcSetDeviceParameter(deviceIndex, PAR_DD_BUFF_SIZE, 100); // buffer [MB]&lt;br /&gt;
	printf(&amp;quot;, %d&amp;quot;, rc);&lt;br /&gt;
&lt;br /&gt;
	rc = pxcMeasureTpx3DataDrivenMode(deviceIndex, measTime, &amp;quot;&amp;quot;, PXC_TRG_NO, onTpx3Data, (intptr_t)&amp;amp;devIdx);&lt;br /&gt;
	printErrors(&amp;quot;pxcMeasureTpx3DataDrivenMode&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// * Data consistency check level : Detection level of ToA data inconsistency.&lt;br /&gt;
// If the chip is overloaded due too many partickes in time, clock can freezeand a ToA inconsistency occurrs.&lt;br /&gt;
// If it is detedted, measuring immediately stopand error “Acquisition failed(Data flow corrupted !!)“ occurrs.&lt;br /&gt;
// Level 50 is some like OFF, level 150 is highest sensitivity.&lt;br /&gt;
&lt;br /&gt;
void onTpx3Data(intptr_t eventData, intptr_t userData) { // ================================&lt;br /&gt;
	int deviceIndex = *((unsigned*)userData);&lt;br /&gt;
	unsigned pixelCount = 0;&lt;br /&gt;
	int rc; // return codes&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetMeasuredTpx3PixelsCount(deviceIndex, &amp;amp;pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;getMeasuredTpx3PixelsCount&amp;quot;, rc, ENTER_OFF);&lt;br /&gt;
	printf(&amp;quot; PixelCount: %u\n&amp;quot;, pixelCount);&lt;br /&gt;
&lt;br /&gt;
	auto result = new Tpx3Pixel[pixelCount];&lt;br /&gt;
	rc = pxcGetMeasuredTpx3Pixels(deviceIndex, result, pixelCount);&lt;br /&gt;
	printErrors(&amp;quot;pxcGetMeasuredTpx3Pixels&amp;quot;, rc, ENTER_ON);&lt;br /&gt;
&lt;br /&gt;
	dataUsingFunction(&amp;amp;result, pixelCount);&lt;br /&gt;
	delete[] result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3PixelsCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the number of measured Timepix3 pixels in data driven mode. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned*  pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixelCount – pointer to output variable for number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa = unsigned int cnt;&lt;br /&gt;
int rc = pxcGetMeasuredTpx3PixelsCount(0, &amp;amp;cnt);&lt;br /&gt;
if (rc==0) printf(&amp;quot;%d pixels from device idx 0 are waiting in memory\n&amp;quot;, cnt);&lt;br /&gt;
else printf(&amp;quot;pxcGetMeasuredTpx3PixelsCount failed, code %d\n&amp;quot;, rc);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
: ToT in output data are ToT in 25ns ticks or energy in keVs, depending on Timepix3CalibrationEnabled&lt;br /&gt;
: See pxcSetTimepix3CalibrationEnabled, pxcIsTimepix3CalibrationEnabled&lt;br /&gt;
| pixelCount – size of the supplied array as number of pixels&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetMeasuredRawTpx3Pixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the measured Timepix3 pixels data in raw format. &#039;&#039;&#039;Timepix3 only.&#039;&#039;&#039;&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, RawTpx3Pixel* pixels, unsigned pixelCount&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – buffer where pixels will be saved&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels to save)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not = Use the pxcGetMeasuredRawTpx3Pixels only in special, exceptional cases.&lt;br /&gt;
| War = See: [[The_RawTpx3Pixel_structure_in_memory|The RawTpx3Pixel structure in memory]]&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcCalibrateTpx3PixelsAndFilter&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum =  Calibrate the pixel data and filter them by energy range&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, Tpx3Pixel* pixels, unsigned* pixelCount, double minEnergy, double maxEnergy&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| pixels – pointer to array of Tpx3Pixels that will be filled with measured pixels&lt;br /&gt;
| pixelCount – size of pixels buffer (number of pixels). It will be filled with the number of pixel remaining after filtration&lt;br /&gt;
| minEnergy – minimal allowed energy of each pixel&lt;br /&gt;
| maxEnergy – maximal allowed energy of each pixel&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
= API frame-data processing functions =&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| [[File:Beam-hardening-bh2c.png|left|frame|alt=Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation|Left: raw image, mid: After beam hardening correction, right: after BHC and bad pixels interpolation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Interpolating of bad pixels ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcInterpolateBadPixels&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Interpolates bad pixels in the image. Uses badPixelsMatrix as bad pixels (badPixel = 1, good = 0)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned char* badPixelsMatrix, double* data, unsigned width, unsigned height&lt;br /&gt;
| badPixelMatrix – matrix of the bad pixels&lt;br /&gt;
| data – data to be interpolated&lt;br /&gt;
| width – width of the image&lt;br /&gt;
| height – height of the image&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the devices&#039;s matrix of bad pixels (bad = 1, good = 0). Bad pixels are pixels that are masked.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned deviceIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Beam hardening correction ==&lt;br /&gt;
The functions described in this chapter can be used to compensate the beam hardening effect, bad pixels and chip sensitivity uneven to get the data with true thickness of measured material.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First step is adding set of the reference images (masks). Dirrect beam (or beam with filter that will be used in all the process) and flat plates with different thicknesses, optimally in whole range that you want measuring. Use the &#039;&#039;&#039;pxcAddBHMask&#039;&#039;&#039;. Reference images contains unsigned 32bit pixels. To create the reference pictures, recommended fold more acquired images to achieve pixel values aproximatelly tens of thousands or more (50,000 is good start). Don’t forget corectly set their thickness.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If 2 or more reference images have been added, it is possible to determine which pixels are not usable. Check this using the &#039;&#039;&#039;pxcGetBHBadPixelMatrix&#039;&#039;&#039; function. If there are too many of these pixels, the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function may lose accuracy and the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039; function will not work. In this case you can check:&lt;br /&gt;
* If the set-up is correct (condition of the reference plates; Is the whole area of the chip good irradiated and covered by the reference plates? Is there an obstacle in the beam?)&lt;br /&gt;
* If there is too much contrast between the references - a common problem, especially between the free beam and the first reference plate - you can use a filter throughout the process&lt;br /&gt;
* If some areas have too low values with high noise - increase the number of integrated frames, beam intensity, or acquisition time&lt;br /&gt;
* If exist areas with overexposition – decrease the time or beam intensity&lt;br /&gt;
* If the instability of the CdTe chip has manifested itself - increase the time by integrating the reference images&lt;br /&gt;
* If using CdTe and measuring start too soon afther chip init&lt;br /&gt;
* Try use other beam energy&lt;br /&gt;
After add sufficient number of reference images, you can measure image of the sample and use the &#039;&#039;&#039;pxcApplyBHCorrection&#039;&#039;&#039; function. Output is array of double, in units from reference thicknesses.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now you can use the &#039;&#039;&#039;pxcGetDeviceAndBHBadPixelMatrix&#039;&#039;&#039; to get array of bad and other unusable pixels. Use this data with the &#039;&#039;&#039;pxcInterpolateBadPixels&#039;&#039;&#039;. If it doesn&#039;t work, you can use only device bad pixels from the &#039;&#039;&#039;pxcGetDeviceBadPixelMatrix&#039;&#039;&#039; function.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
;Example projects&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-auto&#039;&#039;&#039; – Acquision time auto tuning for easy first experiments.&lt;br /&gt;
:: Interactive control in console, text histograms and preview of images. But the code is relatively complex.&lt;br /&gt;
: &#039;&#039;&#039;MiniPixTpx3-Thickness-bath&#039;&#039;&#039; – Bath process, using text config file.&lt;br /&gt;
:: Simple code, but you need to set usable acquisition times.&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcAddBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Adds a new mask (frame) for Beam-Hardening calibration. &lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* data, unsigned size, double frameTime, double thickness&lt;br /&gt;
| data – data of the frame tat will be used as BH mask&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the frame in seconds&lt;br /&gt;
| thickness – thickness of the measured data&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcBHMaskCount&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Returns number of inserted Beam-Hardening masks (frames)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP =&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = Number of masks if successful, otherwise the return value is a PXCERR_XXX code&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcRemoveBHMask&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Removes Beam-Hardening mask (frame)&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = int index&lt;br /&gt;
| index – index of the mask to remove&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcApplyBHCorrection&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Applies the Beam-Hardening correction to supplied frame&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* inData, unsigned size, double frameTime, double* outData&lt;br /&gt;
| inData – data of the frame that will be corrected&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
| frameTime – acquisition time of the measured frame in seconds&lt;br /&gt;
| outData – output data buffer where corrected data will be saved&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the bad pixel matrix from Beam Hardening correction - pixels that cannot be corrected. (bad pixel = 1, good = 0). Must be called after all BH masks are added.&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{ApiBinaryItem&lt;br /&gt;
| Nam = pxcGetDeviceAndBHBadPixelMatrix&lt;br /&gt;
| HeSym = ===&lt;br /&gt;
| Sum = Gets the combined bad pixel matrix from the device and BeamHardening (badpixel = 1, good = 0).&lt;br /&gt;
| DefH = PXCAPI int&lt;br /&gt;
| DefP = unsigned devIndex, unsigned* badPixelMatrix, unsigned size&lt;br /&gt;
| deviceIndex – index of the device, starting from zero&lt;br /&gt;
| badPixelMatrix – output data buffer where bad pixel matrix will be saved&lt;br /&gt;
| size – size of the data - number of pixels (width * height)&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| Ret = 0 if successful, otherwise the return value is a PXCERR_XXX code.&lt;br /&gt;
| Not =&lt;br /&gt;
| War =&lt;br /&gt;
| Exa =&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See: [[Binary_core_API#pxcGetDeviceBadPixelMatrix|pxcGetDeviceBadPixelMatrix]], [[Binary_core_API#pxcInterpolateBadPixels|pxcInterpolateBadPixels]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=== Example ===&lt;br /&gt;
----&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039;&lt;br /&gt;
* [[Beam_hardening_correction:_Bath_example|Beam hardening correction: Bath example]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some images ===&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe vs Si.png|none|alt=CdTe vs Si|CdTe vs Si]]&lt;br /&gt;
|| &#039;&#039;&#039;1. CdTe 2 mm (left) vs Si 0,3 mm (right)&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;CdTe advantages:&#039;&#039;&#039; More sensitive, orders of magnitude shorter acquisition times or lower beam intensities. Have lower energy consumption and and it less warming.&amp;lt;br&amp;gt;&lt;br /&gt;
imgs:&amp;lt;br&amp;gt;&lt;br /&gt;
CdTe: integrated 3.43 sec (25,6 ms subframes)&amp;lt;br&amp;gt;&lt;br /&gt;
Si: integrated 27.7 sec (625 ms subframes)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:CdTe artefacts.png|none|alt=CdTe artefacts|CdTe artefacts]]&lt;br /&gt;
|| &#039;&#039;&#039;CdTe disadvantages:&#039;&#039;&#039; Uneven distribution of chip sensitivity. Slow instability can cause the need for a long total measurement time.&amp;lt;br&amp;gt;&lt;br /&gt;
Specialy thick chips have a easily visible image distortion. Afther start-up, CdTe contains lot of free charges, they can cause problems duringearly measurements (use &#039;&#039;&#039;pxcDoSensorRefresh&#039;&#039;&#039;).&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Si and CdTe have opposite bilas polarity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening setup Bh1a.jpg|thumb|none|alt=beam hardening experimental setup|beam hardening experimental setup]]&lt;br /&gt;
|| &#039;&#039;&#039;2. The beam hardening experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
1 – The sensor&amp;lt;br&amp;gt;&lt;br /&gt;
2 – Pb shielding of electronics (for sure, large intensities were tested in this experiment)&amp;lt;br&amp;gt;&lt;br /&gt;
3 – several thin sheets, a total of 0.3 mm to reduce free beam / first ref. plate contrast&amp;lt;br&amp;gt;&lt;br /&gt;
4 – 0.6 mm reference plates&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam hardening Bh1c.png|none]]&lt;br /&gt;
|| [[File:Beam hardening Bh2c.png|none]] &lt;br /&gt;
|| &#039;&#039;&#039;3. Test images&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Left is Fe bearing, used reference plates and the setup from img. 2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Right is Al plates, 3 and 8 mm, reference plates was several 3mm sheets&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Up – original images&amp;lt;br&amp;gt;&lt;br /&gt;
Mid – afther pxcApplyBHCorrection&amp;lt;br&amp;gt; &lt;br /&gt;
Down – mid afther pxcInterpolateBadPixels &amp;lt;br&amp;gt;&lt;br /&gt;
(range in all images auto-resized to grayscale 0-255)&lt;br /&gt;
|}&lt;br /&gt;
----&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:Beam_hardening_Bh2a.jpg|thumb|none]]&lt;br /&gt;
|| &#039;&#039;&#039;4. The Al plates experimental setup&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1 – Cooler - Si chip used&amp;lt;br&amp;gt;&lt;br /&gt;
2 – The Minipix&amp;lt;br&amp;gt;&lt;br /&gt;
3 – Imaged aluminium plates&amp;lt;br&amp;gt;&lt;br /&gt;
4 – Thin Al sheet to reduce free beam / first ref. plate contrast&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= The synchronizing =&lt;br /&gt;
{|&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
[[File:The synchronizing-Widepix.jpg|200px|none]]&lt;br /&gt;
|| Sometimes it is necessary to synchronized with an external event. Or some instruments, Widepix-L for example, can be organized as set of more than 1 device in 1 box and more than 1 data cable go out. If you want start acquisition on whole instrument at exactly the same time, must use synchronization by the hardware trigger.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Synchronizing basics ==&lt;br /&gt;
The acquisition functions have the TrgStg parameter. The 4th argument &amp;quot;trigger settings&amp;quot; of the pxcMeasureTpx3DataDrivenMode(), for example. This have options:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
|+ &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_NO&#039;&#039;&#039; || No sync. Normally start immediatelly and stop after acqTime.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTART&#039;&#039;&#039; || Slave wait and start the acq. on HW signal, master can wait for slave ready.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Start the acq. immediatelly and stop on HW signal or after acqTime.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_HWSTARTSTOP&#039;&#039;&#039;&amp;lt;br&amp;gt;&amp;amp;nbsp; || Wait and start the acq. on HW signal and stop at next HW signal.&amp;lt;br&amp;gt;(Available only in specific devices, see sync. manual.)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;PXC_TRG_SWSTART&#039;&#039;&#039; || Wait and start the acq. on SW signal = [[Binary_core_API#pxcDoSoftwareTrigger|pxcDoSoftwareTrigger()]].&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Additionally, you must use the named parameters. You can read if the device is ready, is it master, etc and write some parameters. Details depends on the device type. Some devices allow reset the ToA counter without restart acquisition or start acquisition without reset the ToA counter.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;See:&#039;&#039;&#039; [[#Parameter_Get/Set_functions_(using_text_paramName)|Parameter Get/Set functions (using text paramName)]]&lt;br /&gt;
&lt;br /&gt;
== Synchronizing with an external source ==&lt;br /&gt;
Sync with the external source can depends on the device type. See the synchronization manual of your device type for hardware details.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Way to use the external HW sync with the Advapix-Tpx3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1. Set some synchronization parameters: &amp;quot;TrgTimestamp&amp;quot;, &amp;quot;TrgT0SyncReset&amp;quot;, &amp;quot;TrgOutLevel&amp;quot;, &amp;quot;TrgOutEnable&amp;quot; using function to write the named parameters: pxcSetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
2. Read some synchronization parameters: &amp;quot;TrgReady&amp;quot;, &amp;quot;IsMaster&amp;quot; using the pxcGetDeviceParameter.&amp;lt;br&amp;gt;&lt;br /&gt;
3. Start the pxcMeasure... with some PXC_TRG_HW...&amp;lt;br&amp;gt;&lt;br /&gt;
4. Apply the sync signal to the input.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Synchronizing in multi-device instruments ==&lt;br /&gt;
(This text is primary about the WIdepix-L with 2 ethernet cables, if using other device, see the Synchronization manual of your device)&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Decision which device is master&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
    isMaster = pxcGetDeviceParameter(devIdx, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output is 0 for slave, 1 for master or single, &amp;lt;0 if the device not supports param name/type.&amp;lt;br&amp;gt;&lt;br /&gt;
; Note&lt;br /&gt;
: Some devices has &#039;&#039;&#039;IsMaster&#039;&#039;&#039; and some other has &#039;&#039;&#039;TriggerMaster&#039;&#039;&#039;.&lt;br /&gt;
: Some devices has output &#039;&#039;&#039;bool&#039;&#039;&#039; (read as int 0/1) and some other has &#039;&#039;&#039;string&#039;&#039;&#039; (read as char[] &amp;quot;Yes&amp;quot;/&amp;quot;No&amp;quot;)&lt;br /&gt;
: In universal software, expect all 4 combinations to exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Master Setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 0&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
# Set the parameter TriggerOutLevel = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Slave setup&#039;&#039;&#039;&lt;br /&gt;
# Set the parameter TriggerStg = 2&lt;br /&gt;
# Set the parameter TriggerWaitForReady = 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The measurement&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This can be simple if the continuous acquisition is used: This API function starts in separate thread:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
rcs = pxcMeasureContinuous(slvIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)slvIdx);&lt;br /&gt;
rcm = pxcMeasureContinuous(masIdx, bufCnt, acqTime, PXC_TRG_HWSTART, callback, (intptr_t)masIdx);&lt;br /&gt;
errorToList(&amp;quot;pxcMeasureContinuous s,m&amp;quot;, rcs, rcm);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But if using other acq. functions, you must start slave acq. in separate thread manually.&amp;lt;br&amp;gt;&lt;br /&gt;
(see the Visual Studio example “Mpx3-2-sync”)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note Widepix-L&#039;&#039;&#039;&lt;br /&gt;
: If the acquisition time is long, approximately from 100 ms, the run is irregular and there may be long pauses (1 to 5 * acqTime) between acquisitions. This can be suppressed if master acqTime is approximately over 10 % longer.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Widepix-L: The TriggerStg and TriggerOutLevel are linked in the following way:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 0 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 0 || 2 || X&lt;br /&gt;
|-&lt;br /&gt;
| Alternating sync || 0 || 1 || 3 || X&lt;br /&gt;
|-&lt;br /&gt;
| Sync 1:1 || 0 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Synchronizing a multi-device with an external source ==&lt;br /&gt;
&lt;br /&gt;
Set the device normally for synchronizing in multi-device (See chapter above for details), but in the master settings set the TriggerStg alias TrgStg to 2 or 3 by the used edge of trigger signal. Be carefull if using 0 or 1.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Example setting for double-device external sync on rising edge&lt;br /&gt;
|-&lt;br /&gt;
! Function !! Master TriggerStg !! Master TriggerOutLevel !! Slave TriggerStg !! Slave TriggerOutLevel&lt;br /&gt;
|-&lt;br /&gt;
| Ext and 1:1 || 2 || 1 || 2 || X&lt;br /&gt;
|}&lt;br /&gt;
X - the value doesn&#039;t matter&lt;br /&gt;
&lt;br /&gt;
== Multi-device synchronizing examples ==&lt;br /&gt;
These samples are derived from the Mpx3 project from the AdvacamAPIexamples collection.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Global variables of the example:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
unsigned	*collectDevFrameD1 = NULL, *collectDevFrameD2 = NULL; // collected devs all frame data&lt;br /&gt;
unsigned	collectDevFramePxCnt = 0;	// collectDevFrameDx size = devWid * devHei * devCnt * collectImgCnt&lt;br /&gt;
unsigned	devcollectDevsIdx[256];		// list of devs to collect imgs&lt;br /&gt;
int			collectDevsCnt = -1;		// count of devs to be collected (&amp;gt;0 to enable)&lt;br /&gt;
int			collectDevsMasterIdx = -1;	// index of master position in devcollectDevsIdx[]&lt;br /&gt;
unsigned	collectDevWidth = -1, collectDevHeight = -1; // size of collected image&lt;br /&gt;
unsigned	collectImgsMax = 0; // =textColImgsMax-&amp;gt;Text; vertical count of images to be collected&lt;br /&gt;
int			collectDevCntCallbacks, collectDevCntOK, collectDevCntFail; // callbacks img collect status&lt;br /&gt;
&lt;br /&gt;
double		acqTime = 1.0;		// time for acq. functions&lt;br /&gt;
int			frameCount = 0;		// frames count for pxcMeasureMultipleFrames&lt;br /&gt;
								// or cilcular buffer frames count for pxcMeasureContinuous&lt;br /&gt;
int deviceMaxIdx = -1;			// maximal connected dev idx (count-1)&lt;br /&gt;
int deviceIndex = -1;			// index of the single device to be used&lt;br /&gt;
int frameLastIndex = -1;		// index of the frame that was viewed and for saving&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Preparing setup for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Decision if the dev is master (all dev types with internal synchronization):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int isDevMaster(unsigned di) {&lt;br /&gt;
	int rc = pxcGetDeviceParameter(di, &amp;quot;TriggerMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	rc = pxcGetDeviceParameter(di, &amp;quot;IsMaster&amp;quot;);&lt;br /&gt;
	if (rc == 0 || rc == 1) return rc;&lt;br /&gt;
&lt;br /&gt;
	char val[] = &amp;quot;   &amp;quot;;&lt;br /&gt;
	rc = pxcGetDeviceParameterString(di, &amp;quot;TriggerMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc!=0) pxcGetDeviceParameterString(di, &amp;quot;IsMaster&amp;quot;, val, 4);&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		if (strcmp(val, &amp;quot;Yes&amp;quot;) == 0) return 1;&lt;br /&gt;
		else if (strcmp(val, &amp;quot;No&amp;quot;) == 0) return 0;&lt;br /&gt;
		else return MY_ERR_CODE;&lt;br /&gt;
	}&lt;br /&gt;
	return rc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup devices, the textCollectDevsOrd contains device indexes order string, like as &amp;quot;102&amp;quot;, primary used to joining images side by side in the desired order (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
collectDevsCnt = textCollectDevsOrd-&amp;gt;Text-&amp;gt;Length;&lt;br /&gt;
int trgMastCnt = 0;&lt;br /&gt;
for (int n = 0; n &amp;lt; collectDevsCnt; n++) {&lt;br /&gt;
	devcollectDevsIdx[n] = Convert::ToInt32(textCollectDevsOrd-&amp;gt;Text[n] - &#039;0&#039;);&lt;br /&gt;
	if (devcollectDevsIdx[n] &amp;gt; deviceMaxIdx) { // deviceMaxIdx = global, set after init pxcore&lt;br /&gt;
		collectDevsCnt = -1;&lt;br /&gt;
		msgToList(String::Format(&amp;quot;Collect devs: devIdx out of range {0}&amp;quot;, devcollectDevsIdx[n]));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int isMast = isDevMaster(devcollectDevsIdx[n]);&lt;br /&gt;
	if (isMast &amp;lt; 0) {&lt;br /&gt;
		errorToList(&amp;quot;pxcGetDeviceParameter TriggerMaster&amp;quot;, isMast);&lt;br /&gt;
		isMast = 0;&lt;br /&gt;
	}&lt;br /&gt;
	if (isMast == 1) {&lt;br /&gt;
		trgMastCnt++;&lt;br /&gt;
		collectDevsMasterIdx = n;&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	} else {&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerStg&amp;quot;, 2);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerStg&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerWaitForReady&amp;quot;, 1);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerWaitForReady&amp;quot;, rc);&lt;br /&gt;
		rc = pxcSetDeviceParameter(devcollectDevsIdx[n], &amp;quot;TriggerOutLevel&amp;quot;, 0);&lt;br /&gt;
		errorToList(&amp;quot;pxcSetDeviceParameter TriggerOutLevel&amp;quot;, rc);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
if (trgMastCnt != 1 || collectDevsCnt &amp;lt; 2) {&lt;br /&gt;
	msgToList(&amp;quot;Err: 2 or more devs incl. 1 TriggerMaster needed for collect&amp;quot;);&lt;br /&gt;
	collectDevsCnt = -1;&lt;br /&gt;
	collectDevsMasterIdx = -1;&lt;br /&gt;
} else {&lt;br /&gt;
	msgToList(String::Format(&amp;quot;Collect devs setup complete. Master idx/devIdx:{0}/{1}&amp;quot;,&lt;br /&gt;
		collectDevsMasterIdx, devcollectDevsIdx[collectDevsMasterIdx]));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting acquisitions for synchronized Mpx3 multi-device example ===&lt;br /&gt;
This section using the callbacks to get actual data. The userData parameter is used to inform the callback function about source device index in the devcollectDevsIdx[]. Based on the index into devcollectDevsIdx[] and the frame index, a place in the buffer is selected and read from the device is called.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Setup and start the synchronized measurement with using continuous acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Continuous mode is not usable with TDI.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
rc = initMeasParams(&amp;quot;Continuous acq. with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
&lt;br /&gt;
if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip the master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
&lt;br /&gt;
		rc = pxcMeasureContinuous(di, frameCount, acqTime, PXC_TRG_HWSTART, clbContinuousAcq,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} pxcMeasureContinuous {2} {3}&amp;quot;,&lt;br /&gt;
			n, di, rc, (rc==0)? &amp;quot;OK&amp;quot;: &amp;quot;failed&amp;quot;));&lt;br /&gt;
		if (rc != 0) return;&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	// pxcMeasureContinuous(unsigned deviceIndex, unsigned frameBufferSize, double frameTime, unsigned trgStg = PXC_TRG_NO, FrameMeasuredCallback callback = 0, intptr_t userData = 0);&lt;br /&gt;
	rc = pxcMeasureContinuous(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbContinuousAcq, NULL);&lt;br /&gt;
	errorToList(&amp;quot;pxcMeasureContinuous&amp;quot;, rc);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Setup and start the synchronized measurement with using multi-acquisition.&amp;lt;br&amp;gt;&lt;br /&gt;
A bit more complicated, but works with TDI as well.&amp;lt;br&amp;gt;&lt;br /&gt;
(Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
int rc;&lt;br /&gt;
DWORD dwThrID;&lt;br /&gt;
HANDLE h;&lt;br /&gt;
&lt;br /&gt;
int rc = initMeasParams(&amp;quot;More frames with callback test&amp;quot;, true, true); // set-up buffers, operation mode and other measurement settings&lt;br /&gt;
if (rc!=0) return;&lt;br /&gt;
if (collectDevsCnt&amp;gt;0) {&lt;br /&gt;
	for (int n = 0; n &amp;lt;= collectDevsCnt; n++) {&lt;br /&gt;
		if (n == collectDevsMasterIdx) continue; // skip master and start it at end&lt;br /&gt;
		int di = devcollectDevsIdx[n];&lt;br /&gt;
		if (n == collectDevsCnt) di = devcollectDevsIdx[collectDevsMasterIdx];&lt;br /&gt;
		sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(di, frameCount, acqTime, PXC_TRG_HWSTART, clbFramesWC,&lt;br /&gt;
			(n &amp;lt; collectDevsCnt) ? n : collectDevsMasterIdx);&lt;br /&gt;
		h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
		msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} OK&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
		if (h == NULL) {&lt;br /&gt;
			msgToList(String::Format(&amp;quot;n:{0} di:{1} CreateThread {2} failed&amp;quot;, n, di, (int)dwThrID));&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
} else {&lt;br /&gt;
	sMeasureMultFrsCallbackPars* thrData = new sMeasureMultFrsCallbackPars(deviceIndex, frameCount, acqTime, PXC_TRG_NO, clbFramesWC, NULL);&lt;br /&gt;
	h = CreateThread(NULL, 0, MeasureMultFrsCallbackThrFn, (void*)thrData, 0, &amp;amp;dwThrID);&lt;br /&gt;
	msgToList(&amp;quot;pxcMeasureMultipleFramesWithCallback - thread &amp;quot; + System::Convert::ToString((int)dwThrID));&lt;br /&gt;
	if (h == NULL) return;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Callbacks for synchronized Mpx3 multi-device example ===&lt;br /&gt;
Collecting the image data, called from callbacks (Tested with Widepix, ethernet or USB):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// idx of devcollectDevsIdx, frame idx&lt;br /&gt;
void collectDevImgs(unsigned ndi, unsigned fIdx) {&lt;br /&gt;
	int rc;&lt;br /&gt;
	&lt;br /&gt;
	size_t		adrAdd = static_cast&amp;lt;size_t&amp;gt;(devPixels * (ndi + (fIdx % collectImgsMax) * collectDevsCnt));&lt;br /&gt;
	unsigned	*cd1 = collectDevFrameD1 + adrAdd;&lt;br /&gt;
	unsigned	*cd2 = collectDevFrameD2 + adrAdd;&lt;br /&gt;
	unsigned	bs = collectDevFramePxCnt - adrAdd;&lt;br /&gt;
&lt;br /&gt;
	if (bs &amp;lt; 0x80000000) {&lt;br /&gt;
		rc = pxcGetMeasuredFrameMpx3(devcollectDevsIdx[ndi], fIdx, cd1, cd2, &amp;amp;bs);&lt;br /&gt;
	} else rc = MY_ERROR_CODE;&lt;br /&gt;
&lt;br /&gt;
	collectDevCntCallbacks++;&lt;br /&gt;
	if (rc == 0) {&lt;br /&gt;
		collectDevCntOK++;&lt;br /&gt;
	} else {&lt;br /&gt;
		collectDevCntFail++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callbacks:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
// callback function for &amp;quot;frames with callback&amp;quot;&lt;br /&gt;
void clbFramesWC(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	frameLastIndex = acqCount-1;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// callback function for continuous acquisition&lt;br /&gt;
void clbContinuousAcq(intptr_t acqCount, intptr_t userData) {&lt;br /&gt;
	if (acqCount&amp;lt;0) {&lt;br /&gt;
		clbError = acqCount;&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	frameLastDevIdx = (int)userData;&lt;br /&gt;
	clbCnt++;&lt;br /&gt;
&lt;br /&gt;
	if (acqCount&amp;lt;frameCount) {&lt;br /&gt;
		frameLastIndex = acqCount - 1;&lt;br /&gt;
	} else {&lt;br /&gt;
		if (++frameLastIndex&amp;gt;=acqCount) frameLastIndex = 0;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if (collectDevsCnt &amp;gt; 0) {&lt;br /&gt;
		collectDevImgs((unsigned)userData, frameLastIndex);&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=C&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rearranging measured data to complete image ===&lt;br /&gt;
When all measurements are complete, the data is arranged in memory so that each frame from each device occupies a contiguous area. In order for images to be connected when displaying, each line of the resulting image must contain lines from individual neighboring devices.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Rearranging data from two adjacent sub-devices and three images &lt;br /&gt;
|-&lt;br /&gt;
! Measured data in memory !! style=&amp;quot;width:50px;&amp;quot; rowspan=7 |  !! colspan=2| Rearranged data in memory&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 0&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 0&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 1&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 1&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 0 / frame 2&lt;br /&gt;
| style=&amp;quot;height:60px; width:200px; text-align:center;&amp;quot; rowspan=2 |device 1 / frame 2&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;height:30px; width:400px; text-align:center;&amp;quot; |device 1 / frame 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line=&amp;quot;&amp;quot; lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
compiledFr1 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
//compiledFr2 = (unsigned*)malloc(collectDevFramePxCnt * sizeof(unsigned));&lt;br /&gt;
&lt;br /&gt;
compiledImgData1 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
//compiledImgData2 = (int*)malloc(collectDevFramePxCnt * sizeof(int));&lt;br /&gt;
&lt;br /&gt;
if (!compiledFr1 || !compiledImgData1) {&lt;br /&gt;
	msgToList(&amp;quot;viewCollectedDevsFrs: Memory allocation failed&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	if (compiledFr1) free(compiledFr1);&lt;br /&gt;
	if (compiledFr2) free(compiledFr2);&lt;br /&gt;
	if (compiledImgData1) free(compiledImgData1);&lt;br /&gt;
	if (compiledImgData2) free(compiledImgData2);&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
size_t adrAddIn = 0, adrAddOut = 0;&lt;br /&gt;
// adrAdd = devPixels * ndi   +   collectDevsCnt * devPixels * (fIdx % collectImgsMax);&lt;br /&gt;
for (size_t fi = 0; fi &amp;lt; collectImgsMax; fi++) {			// frames&lt;br /&gt;
	for (size_t lin = 0; lin &amp;lt; collectDevHeight; lin++) {	// lines of single frame&lt;br /&gt;
		for (size_t ndi = 0; ndi &amp;lt; collectDevsCnt; ndi++) {	// subdevices idxs in collectDevsCnt&lt;br /&gt;
			adrAddIn = collectDevsCnt * devPixels * fi + devPixels * ndi + devWidth * lin;&lt;br /&gt;
&lt;br /&gt;
			if (checkCollectReverseLines-&amp;gt;Checked) {&lt;br /&gt;
				for (size_t x = 0; x &amp;lt; devWidth; x++) {&lt;br /&gt;
					(compiledFr1 + adrAddOut)[x] = (collectDevFrameD1 + adrAddIn)[devWidth - x];&lt;br /&gt;
					//(compiledFr2 + adrAddOut)[x] = (collectDevFrameD2 + adrAddIn)[devWidth - x];&lt;br /&gt;
				}&lt;br /&gt;
			} else {&lt;br /&gt;
				memcpy(compiledFr1 + adrAddOut, collectDevFrameD1 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
				//memcpy(compiledFr2 + adrAddOut, collectDevFrameD2 + adrAddIn, devWidth * sizeof(unsigned));&lt;br /&gt;
			}&lt;br /&gt;
			adrAddOut += (size_t)devWidth;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
colorizeData(compiledFr1, compiledImgData1, collectDevFramePxCnt);&lt;br /&gt;
Bitmap^ bmp1c = gcnew Bitmap(collectDevWidth, collectDevHeight * collectImgsMax, collectDevWidth * 4, System::Drawing::Imaging::PixelFormat::Format32bppRgb, (IntPtr)compiledImgData1);&lt;br /&gt;
pictureBox3-&amp;gt;SizeMode = PictureBoxSizeMode::StretchImage;&lt;br /&gt;
pictureBox3-&amp;gt;Image = bmp1c;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related =&lt;br /&gt;
* [[Pixet SDK]]&lt;br /&gt;
* [[Files and directories of the Pixet and SDK#Main directory of the API-using programs, independent on the Pixet|Files and directories: Main directory of the API-using programs]]&lt;br /&gt;
* [[File types]]&lt;/div&gt;</summary>
		<author><name>HudecekP</name></author>
	</entry>
</feed>